C++ reading text file Problem

we want to read some data from text file and we want to assignment these values to x and y values..a data is just like below in tezt file:
30,59
23,54
45,65
...
we tried the below program but it doesnt give proper result...it goes an infinite loop...please help..
using namespace std;

int main()
{

ifstream inFile("input.txt");

while (!inFile.eof())
{
int x;
inFile >> x;
if( inFile.eof() ) break;
cerr << x << endl;

}

return 0;
}
Last edited on
1
2
3
4
5
6
7
8
cout<<"Enter the name of the file: ";
	cin>>filename;
	fin.open(filename, ios::in);
    char str[255];
	while ( !fin.eof() ){
		fin.getline(str,255);
		cout<<str<<"\n";
	}


Here it is :)
thank you very much for your help:)
Topic archived. No new replies allowed.