When C++ is input, should the input of strings precede the shaping?
In fact, Journey to the West 93 answered for the right reason. Before getting (a), the buffer of cin should be emptied. But you should not use clear, which is to clear the error flag of the stream. The correct method is as follows:
int main()
{
int len,start,len 1;
char strTemp[80]; //Clear buffer usage
char a[20];
CIN & gt; & gt start;
CIN & gt; & gtlen 1;
cin.getline(strTemp,79); //clear the buffer of cin.