infinite loop in read of a .bas for lexical scanner

i'm building a lexical scanner. for some reason when it gets to the read of my .bas it starts an infinite loop and i can't see why. any help would be appreciated. (input below)

1
2
3
4
5
6
7
8
9
10
11
void readEmBas(string prg[]) 
{
	ifstream inf("prog1.bas");
	int i = 0;
	string st;
	while (!inf.eof()) 
	{
		getline(inf, prg[i]);
		i++;
	}
}


prog1.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
10 rem
12 input x1,y
13 If x1 < y Then GoTo 15
14 zee =x1 - y
11 goto 16
15 zee = x1 + 2 *y
16 print x1, y, zee
17 For i = 1 To 16 Step 5
18 print i
19 next i
20 input st%
21 print "$", st%
22 input x
23 if y >= x1 then x = y^3
24 print x1, #
25 end
Hello TheJast

I have several questions:

1_ Have you initialised your string array prg, if yes how do you know the number of lines that are to be read from the file? Why not use a vector instead?

2_ Why do you have an iterator i if it doesn't come to any use? As far as I see you're not using it for anything. Same goes for your string st.

3_ You say that you're getting stuck in an infinite loop, what is your input and what loop are you stuck in?

Could you post more of your program (if not all of it), it's hard to tell what's going wrong with just what you shared?
Topic archived. No new replies allowed.