-
April 15th, 2014, 09:47 PM
#1
code stuck at getline...
my code is not moving past the line below...actually i am making a quiz and this piece of code id checking whether the entered answer is correct, from a file.
please tell me the possible reason for the problem..
Code:
getline(anss,saveans);
Code:
while(a<1)
{
getline(anss,saveans);
if (saveans == ToString(randNum))
{
getline(anss,saveans);
if (saveans == ans)
{
cout<<"correct!"<<endl;
cout<<"# next question # "<<endl;
}
else
{
cout<<"wrong answer!"<<endl; // Prints our STRING
cout<<"# next question # "<<endl;
}
break;
}
}
-
April 15th, 2014, 10:59 PM
#2
Re: code stuck at getline...
Point some breakpoints in your code and step through the code in a debugger. If you do this, the errors will become obvious.
-
April 15th, 2014, 11:22 PM
#3
Re: code stuck at getline...
I have tried it and found that it is not able to read the file that stores the answers...I cannot find the reason since the similar code is working in other part of my code that uses a different file...pls help
-
April 16th, 2014, 12:08 AM
#4
Re: code stuck at getline...
Rather than reading the file one question at a time, read the whole file and store each line in a collection.
-
April 16th, 2014, 01:02 AM
#5
Re: code stuck at getline...
i dont know how to do that?
how is it done..?
-
April 16th, 2014, 01:14 AM
#6
Re: code stuck at getline...
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|