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..
 
getline(anss,saveans);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
				}
			}
Are you using the while loop or the do while loop..?
Also whats the program finding?
i am using a while loop...and i m making a quiz ...this peice of code checks the answer entered is correct or not...randNum represents the question no...
actually this code has one more part which asks a question read from a text file...and the code together is working ...but my project is to make an object oriented program...so i have split the code into 2 and now it is stuck at line 3..the other part is working fine..
i can give u a link if u wud like to see the whole code...i insist u take a look please...i m in deep trouble...
http://www.cplusplus.com/forum/general/129193/
i have solved de problem...try it
it is still not working...

okay..let me try it again
did u find anything?
yea..you need to include <cstdlib> to the library
thanks for the effort but i found the error...i just wrote "ans.text" instead of "ans.txt"......that was it ..the code ran...:)
thanx anyways..:)
thnx too
Topic archived. No new replies allowed.