0

Any help would be appreciated with this program :

I have a file with 5 lines....each line has name, id , phone ...etc...
I have to read that intro an array of structures and display the results.
This is what I have so far .. I doesn't not display anything

#include <iostream>
#include <fstream>
#include <string>
#include<iomanip>

using namespace std;

struct StudentInfo
{
    string name;
	int account_id, phone;
	float checking, saving;
};

int main ()
{
	ofstream file1; 
    const int MaxSize = 5;
    StudentInfo myarray[MaxSize]; 

	file1.open ("users.txt");
	
for (int i=0; i<MaxSize; ++i)
{	

      file1<<myarray[i].name; 
	  file1<<myarray[i].account_id;
	  file1<<myarray[i].saving;
	  file1<<myarray[i].checking;
	  file1<<myarray[i].phone<<endl<<endl;
           
}

   
		
//    }
    return 0;
}

Edited by WaltP: Added CODE Tags -- please use them.

4
Contributors
4
Replies
12
Views
6 Years
Discussion Span
Last Post by abhimanipal
0

The file exists already . I just thaught I might be able to assignt with studentifo myarray[maxsize]. in the loop I think that every line in the file will be stored in the array. I don't have to input anything in the file . Just read and output 5 students into array and display . I'm really not c++ savvy . All I need is a good direction

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.