Code:
while(!fin.eof())
{
system("cls");
for(i = 0; i < 500; i++)
{
szEdit[i] = new char[256];
}
fin.getline(buffer, 256);
strcpy(szEdit[i], buffer);
fin.close();
}
}
Lets follow the logic here a minute:
Code:
while not EOF
do
clear screen
Loop i from 0 to 499
szEdit[i] = new memory size(256)
EndLoop
get one line in buffer
Copy buffer to szEdit[500] /* Oops, out of bounds */
close file
end do
- Whats the outer while loop for?
- Note the out of bounds comment.
Code:
if(fout.fail())
{
printf("Error, Returning to main menu");
menu();
}
It looks like you created a recursive problem here. Instead of calling menu(), did you mean to return instead?