Infinite loop while printing the file contents

Hi,

I have the below piece of code which reads a file line by line and prints the contents to another file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
char finalLine[255];
ifstream inActive_pmc;
inActive_pmc.open (active_pmc); // active_pmc is a file with some contents
	
if(inActive_pmc.is_open())
{
	while(!inActive_pmc.eof()) // To get you all the lines.
 	{
		memset (finalLine, '\0', sizeof(finalLine));
		inActive_pmc.getline(finalLine,255);
		cout << finalLine <<endl;
	}

}


The problem is the control is not coming out of this loop at all. And also it is not printing any contents of the file too. It just keeps printing empty lines. Any inputs on this?? Please help.
use while(getline(ifstream, string))
Hi Aramil of Elixia,

Thanks for your time on this.
I would be grateful if you can explain what is the problem with my implementation..

Thanks in advance.
i dont know what it is but i was told it was better to use getline(inActive_pmc, string) as the while loop condition because it keeps getting the next line
Topic archived. No new replies allowed.