While with more than one string

I have a dat file and am trying to cout more than one string.
Anyone have a clue?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{

ifstream inputFile;
int one;
string name;
int two;
double number;

inputFile.open("thefile.dat");
//Loop That I am lost on
while (inputFile >>         )
{
//And to cout the multiple strings that they were read in
cout <<      <<endl;
}
inputFile.close();          

Can't help without knowing the format of the data file.
1
Name
1000
100
2
Name
2000
200
etc
Anyone have an idea? I searched all over this site and others and can not find any good examples
Since you have one item per line and lines grouped into fours, you're going to need to do four cins and four couts inside your loop.

1
2
3
4
5
6
7
8
  while (inputfile >> one)
  {  // read the remaining three lines
      inputfile >> name;
      inputfile >> two;
      inputfile >> number;
      //  Now write out the values
      cout << one << ',' << name << ',' << two << ',' << number << endl;
  }

Topic archived. No new replies allowed.