Hey everyone.
SO I just started my first C++ class and we are working on a Lab assignment.
All I need to do is make a program that reads this
Sandra King 75 62 84 98 96 86 70
Jason Briggs 82 71 65 72 81 95 90
Tina Simpson 55 60 62 54 55 68 31
from a .txt file
displays the names LastName, FirstName
and the average grade for each student.
My problem is that I can't for the life of me figure out how to get
the program to read the text. This is my 3rd program I have ever tried to build
and my progress is honestly pathetic.
Any help is much appreciated. Or even if you could tell me what to put in a
search bar to find this out would be great. Everything I've looked for only
show writing text to files, and reading files and printing them.
But I can find anything about how to turn the data into integers
heres what Ive got so far thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char** argv) {
ifstream inputFile;
string name;
inputFile.open("grades");
inputFile >> name;
cout << name << endl;
inputFile >> name;
cout << name << endl;
inputFile >> name;
cout << name << endl;
inputFile.close();
return 0;
}
|
I know it's not much but at the moment im just trying to get the names to at lease print. all im getting back in the terminal is whitespace.... well blackspace i guess but you get my point. Thanks. Forgive my ignorance.