you are not incrementing the value of
i
by 1 as below(infinite loop)
const char *filename = "test.txt";
ifstream fin(filename);
char tmp[80];
while(!fin.eof()){
int i = 0;
fin.getline(tmp,80);
while(tmp[i] != '\0')
{
std::cout << tmp[i];
i++;
}
std::cout<<"\n";
if(fin.fail() && !fin.eof()){
fin.clear();
if(fin.peek() == '\0')
fin.get();
}
}
also changed the code to print one line as in the file