Guest_imported
New member
- Jan 1, 1970
- 0
hi all,
brb..Thanks for all your help..
I have work onn my codes and still cant get it to do what it suppose to. Im so mad at myself! Can anyone help me please..This is what It spose to do.
Write a program that
1.Read all information from the file "data.txt" such that all students’ scores are stored in 2-d array Scores[9][8] of type int, all last names are stored in a char array LastName[9][10], all first names are stored in a char array FirstName[9][10], and the title line is stored in a char array FirstLine[80].
-------------------------------------------------------
this is the content of data.txt file,
------------------------------------------------------
T1 T2 T3 T4 T5 T6 T7 T8
Gigalo, Donald 8 9 10 7 9 82 76 72
Lennon, John 6 8 9 7 8 68 74 83
Garriss, Tom 10 10 10 10 10 100 100 100
Marriss, Nick 9 8 9 8 9 90 80 90
Ivano, Erikas 6 5 4 0 0 65 58 34
----------------------------------------------------------
This is the code I have so far.Its not quite finish. I cant get C++ to read in the score into Score[9][8] array.Also
I am not sure if I read the LastName[9][10] and
FirstName[9][10] right either.
--------------------------------------------------
#include<iostream>
#include<fstream>
using namespace std;
void main ()
{
int Score[9][8],row,col;
char Firstline[80],LastName[9][10],FirstName[9][10];
ifstream Infile("record.txt"
//////////////////////////////////////////////Initializer block
for(int b=0;b<80;b++)
{
Firstline=' ';
}
for(row=0;row<9;row++)
{
for(col=0;col<10;col++)
{
LastName[row][col]=' ';
FirstName[row][col]=' ';
}
}
for(row=0;row<9;row++)
{
for(col=0;col<8;col++)
{
Score[row][col]=0;
}
}
///////////////////////////////////////////////Reader block
while(Infile.good())
{
Infile.get(Firstline,80,'\n');
for( row=0;row<9;row++)
{ Infile.get(LastName[row],10,',');
Infile.get(FirstName[row],10,' ');
}
}
/////////////////PRINTERs//////////////////////////////
for(int a=0;a<80;a++)
{
cout<<Firstline[a];
}
for(int d=0;d<9;d++)
{
cout<<LastName[d];
cout<<FirstName[d];
}
}
brb..Thanks for all your help..
I have work onn my codes and still cant get it to do what it suppose to. Im so mad at myself! Can anyone help me please..This is what It spose to do.
Write a program that
1.Read all information from the file "data.txt" such that all students’ scores are stored in 2-d array Scores[9][8] of type int, all last names are stored in a char array LastName[9][10], all first names are stored in a char array FirstName[9][10], and the title line is stored in a char array FirstLine[80].
-------------------------------------------------------
this is the content of data.txt file,
------------------------------------------------------
T1 T2 T3 T4 T5 T6 T7 T8
Gigalo, Donald 8 9 10 7 9 82 76 72
Lennon, John 6 8 9 7 8 68 74 83
Garriss, Tom 10 10 10 10 10 100 100 100
Marriss, Nick 9 8 9 8 9 90 80 90
Ivano, Erikas 6 5 4 0 0 65 58 34
----------------------------------------------------------
This is the code I have so far.Its not quite finish. I cant get C++ to read in the score into Score[9][8] array.Also
I am not sure if I read the LastName[9][10] and
FirstName[9][10] right either.
--------------------------------------------------
#include<iostream>
#include<fstream>
using namespace std;
void main ()
{
int Score[9][8],row,col;
char Firstline[80],LastName[9][10],FirstName[9][10];
ifstream Infile("record.txt"
//////////////////////////////////////////////Initializer block
for(int b=0;b<80;b++)
{
Firstline=' ';
}
for(row=0;row<9;row++)
{
for(col=0;col<10;col++)
{
LastName[row][col]=' ';
FirstName[row][col]=' ';
}
}
for(row=0;row<9;row++)
{
for(col=0;col<8;col++)
{
Score[row][col]=0;
}
}
///////////////////////////////////////////////Reader block
while(Infile.good())
{
Infile.get(Firstline,80,'\n');
for( row=0;row<9;row++)
{ Infile.get(LastName[row],10,',');
Infile.get(FirstName[row],10,' ');
}
}
/////////////////PRINTERs//////////////////////////////
for(int a=0;a<80;a++)
{
cout<<Firstline[a];
}
for(int d=0;d<9;d++)
{
cout<<LastName[d];
cout<<FirstName[d];
}
}