0 Replies - 783 Views - Last Post: 28 September 2016 - 08:12 AM

#1 dekelelia1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-September 16

store data in array / calculate data for file/ rewrite to the same oil

Posted 28 September 2016 - 08:12 AM

hello everyone, I'm a bit stuck right now.
i don't know exactly how to start , store and calculate the data from a file. this is what i have right now:


int main()
{
string data ;
ifstream myfile ("student_data.txt");
int students[16] = {} ;
const int array_size = 16;
int student[array_size];
int i = 0 ;

if(myfile.is_open())
{
while(getline(myfile,data))
{
istringstream iss(data);
int foo;
while(iss >> foo)
{
student[i]=foo;
cout << student[i] <<" ";
i++;
}

cout << i << endl;
i = 0;

{
cout << foo;
}

}



myfile.close();
}

thats is how it supposed to look :
Stdnt Id Ex ------- Assignments --------- Tot Mi Fin CL Pts Pct Gr
-------- -- ----------------------------- --- -- --- -- --- --- --
75359264 14 20 11 13 9 20 13 20 11 13 9 130 78 81 8 311 78 C+
90774483 39 19 20 20 9 17 19 15 18 13 10 151 55 72 8 325 81 B-
91817488 40 16 14 18 20 18 9 5 15 19 16 145 58 81 9 333 83 B
96666943 33 9 19 15 18 12 18 9 7 19 19 138 57 70 0 298 75 C
22397483 31 18 11 15 19 13 20 9 17 20 15 148 59 64 8 310 78 C+
51659342 22 19 12 15 17 15 20 14 14 20 16 150 79 89 3 343 86 B
01234567 22 18 11 17 20 18 18 5 18 20 18 158 60 56 8 304 76 C
96498948 22 10 12 12 18 20 13 17 9 18 9 129 63 67 8 289 72 C
...


can someone give me some pointers/explanations how to start?
thanks!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1