PLEASE HELP ME!! project on arrays and reading from files

*********I am a new c++ learner and was having trouble with my code.***********

This is the assignment

********************************************************************************

In this lab, you are asked to design a struct that contains the following information:

Name : a string of 10 letters
Account_ID: int
Checking: float
Saving: float
Phone_number: string


Declare an array of 5 structs that hold the information read from a file
Use a loop to print the information of every element in the array

*******************************************************************************

This is my code. Any help will be helpful, i have been stuck on why cin>> wont work and how to loop so it can print the information.

********************************************************************************
#include <iostream>
#include <fstream>
#include <cstdlib>

int main()

{

using namespace std;
ifstream in_stream;
ofstream out_stream;


string name[10];
int Accnt_id[6];
float checking[6];
float saving[7];
string Phone_numb[10];

in_stream.open("infile.dat");

cout<< "Please enter a name"<<endl;
cin >>name>>;

for (name[10]=0;name[10] < 5,name[10]++)// loop name to ask 5 times

cout<< "Please enter account ID";
cin>> Accnt_id >>;

for (Accnt_id[6],=0;Accnt_id[6];<5,Accnt_id[6]++);//loop accnt_id to ask 5 times


return 0;
}
Last edited on
you should not use the array inside the for loop parameter use another variable... an integer

do you need to input 10 name, acct id... etc?
why is the other variable has only 6, 7 array size?
Last edited on
Thanks wwwiii.

are you saying don't use the for loop at all? or change
for (name[10]=0;name[10] < 5,name[10]++)

to

for (int name=0;int name< 5,int name++)?

and i need to input 1 for each accnt_id, checking, saving, phone_numb for 5 names
Last edited on
for(int i=0; i<5; i++){
cout<<"enter name"<<endl
cin>>name[i]>>;
....etc
}

like this
Topic archived. No new replies allowed.