-3
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
int x,y;
char direction ;
char str1[10];
cout<<"Please enter the initial position of the bot";
cin>>x>>y;
cout << "\n\n";
cout << "enter initial direction in caps (F-forward,L-left,R-right)";
cin >> direction;
//cout << "chosen direction :" << direction ;
cout << "\n\n";
cout << "Enter the moves \n(Without space comma seperated in caps eg-F,L,L" ;
cin.get(str1,10);
cout << "entered moves :" << str1 << endl ;
return 0;
}
执行之后: $ ./intern 请输入bot1的初始位置2为什么程序在cin后跳过cin.get()?
进入盖(F-向前,L-左,R-右)初始方向F
进入移动 (如果没有盖分隔空间逗号如-F,L,Lentered移动:
KARPAGAVALLI @阿什温〜 $
您是否考虑过使用调试器逐步完成代码? –
我直接编译它在cygwin –
“...编译器退出...” - 不。编译器不会退出,您的*编译*程序。编译器作业在遇到问题之前已经完成很久。 –