我在使用調試器的代碼中遇到問題(Visual C++ & Bloodshed Dev C++),它只是簡單地跳過一行代碼,或者應該輸入的地方。下面的代碼:C++調試器在控制檯中跳過簡單的代碼行
for(x = 0; x < TASKLIMIT; ++x)
{
cout<<"Enter the name of a task: ";
getline(cin, task[x].name);
cout<<"Enter the priority of the task: ";
cin>>task[x].priority;
while (task[x].priority > 10 || task[x].priority < 1)
{
cout<<"Enter a number from 1-10: ";
cin>>task[x].priority;
}
cout<<"Enter the estimated completion time of the task: ";
cin>>task[x].completion;
cout<<"Enter the deadline of the task: ";
cin>>task[x].deadline;
}
問題偶爾首先它是在該行
cin>>task[x].deadline;
然後它移動移動線:
getline(cin, task[x].name);
時,它得到的第二次迭代for loop
任何幫助將不勝感激
它跳過了哪行代碼? – 2013-03-22 01:14:04
最有可能的,這些90%欺騙:http://stackoverflow.com/search?q=+%5Bc%2B%2B%5D+getline+skipping – chris 2013-03-22 01:15:08
我編輯它來顯示特定行,對不起 – user2197406 2013-03-22 01:16:18