【发布时间】:2017-08-18 14:34:22
【问题描述】:
我遇到了一个问题,每当我运行此代码并在 studentName 输入中放置一个空格时,程序都会跳过下一个问题然后结束。
这就是我在学生姓名中有空格时的样子:
http://i.imgur.com/P4WGfcU.png
这就是它的样子:
http://i.imgur.com/1d9oCMy.png
这是我的代码:
string className;
int classTime;
string studentName;
cout<< setw(50);
cout << "Enter the students name: ";
cin >> studentName;
cout << "Enter first class name: ";
cin >> className;
cout << "---------------------------------------------------------------
----------" << endl;
cout << "|" << studentName << "|Monday |Tuesday|Wensday |Thursday|Friday|Saturday|Sunday|" << endl;
cout << "-------------------------------------------------------------------------" << endl;
cout << "| 9:00-10:00 | | | | | | | |" << endl;
cout << "-------------------------------------------------------------------------" << endl;
cout << "| 10:00-11:00| | | | | | | |" << endl;
cout << "-------------------------------------------------------------------------" << endl;
cout << "| 11:00-12:00| | |" << className << "| | | | |" << endl;
【问题讨论】:
-
调试器。使用调试器。这是使用调试器的完美示例。调试器将允许您一次执行一条语句,并观察变量的值。
-
请使用输入和输出的文本而不是图像来编辑您的帖子。
-
@ThomasMatthews:听起来像是 Tony The Pony 帖子的开始:D
标签: c++