Hi...I am not able to input text file correctly as desired......
data.txt
--------
Jim A
James A+
Smith
Cathy D
Dazy
Peter C
I am suppose to input the above file and fill the above data in two seperate arrays.
For the second column, I am suppose fill NULL value in the array for the missing values corresponding to Smith and Dazy.
here is my code.
string name, grade;
ifstream infile;
infile.open("data.txt",ios::in);
if(infile.fail())
{
cout << "Error opening file";
}
else
{
for(int i=0;i<6;i++)
{
infle >> name[i] >> grade[i];
cout << name[i] << "\t" << grade[i];
}
infile.close();
}
Can somebody please help me out. The output I get is wrong. I don't know how fill NULL in grade array for the missing values.