new >> how would i read a file that has 3 columns and each column contains 100 numbers into an array

Posted by user320950 on Stack Overflow See other posts from Stack Overflow or by user320950
Published on 2010-04-24T20:51:16Z Indexed on 2010/04/24 20:53 UTC
Read the original article Hit count: 234

Filed under:
|
|
int exam1[100];// array that can hold 100 numbers for 1st column 
int exam2[100];// array that can hold 100 numbers for 2nd column 
int exam3[100];// array that can hold 100 numbers for 3rd column  

void main() 
{ 
  ifstream infile;   

  int num; 
  infile.open("example.txt");// file containing numbers in 3 columns 
     if(infile.fail()) // checks to see if file opended 
    { 
      cout << "error" << endl; 
    } 
       while(!infile.eof()) // reads file to end of line 
      { 
         for(i=0;i<100;i++); // array numbers less than 100 
           { 
        while(infile >> [exam]); // while reading get 1st array or element 
            ???// how will i go read the next number 
            infile >> num; 
          } 
      } 
  infile.close(); 
} 

© Stack Overflow or respective owner

Related posts about file

Related posts about array