Loop problem

hey can someone please tell me how to loop this code :

#include <stdafx.h>
#include <iostream>
#include <ctime>
#include <fstream>
#include <string>
using namespace std;


int main ()
{

// string name;
ifstream infile;
string GO;
string name;
string value;
string cost;
string number;
infile.open ("names.txt");
//if (!infile)
//cout << "Error" << endl;
//else
{
infile >> GO >> name >> number >> value >> cost;
while (!infile.eof())
{
cout << GO << "\t" << name << "\t" << number << "\t" << value << "\t" << cost << "\t" << endl;
//if(value=="GO")
//{cout << "Input failed";}
//else cout << "Great" << endl;
system ("pause");
}
cout << endl;
}

return 0;
}

I have been trying to make it loop for ages as i need it to carry on from the first line it displays all the way up to the last line.

Thanks in advance
Use a do-while loop.

1
2
3
4
do
{
    // Code goes here.
}while( conditional );
Topic archived. No new replies allowed.