- 論壇徽章:
- 0
|
#include <iostream.h>;
void main()
{
char str[128];
cout<<"type in a line of text and press enter"<<endl;
cin.getline (str,sizeof(str),'x');
cout <<"first line:"<<str<<endl;
cin.getline (str,sizeof(str));
cout <<"second line:"<<str;
}
運行結(jié)果:
type in a line of text and press enter
you should look "x" up in the subject catalogue.
first line:you should look "
second line:" up in the subject catalogue.
我的問題是當輸入“you should look "x" up in the subject catalogue.”時,cin.getline (str,sizeof(str),'x');這條語句語句不是應該執(zhí)行完了嗎,為什么“x”后面的內(nèi)容也輸入進來了,請指教。
謝謝! |
|