pls help me with my pajeet tier c++ code. im trying to read data from a file into arrays but im getting error messages and it isnt reading my shit right.
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main()
{
const int MAX_ROWS = 40, MAX_COLS = 7;
ifstream SourceFile;
int row = 0, Rows = 0, col, Cols, Scores[MAX_ROWS][MAX_COLS];
string Filename, Names[MAX_ROWS];
for (row = 0; row < MAX_ROWS; row++)
for (col = 0; col < MAX_COLS; col++)
Scores[row][col] = -1;
for (int i = 0; i < MAX_ROWS; i++)
Names[i] = -1;
cout << "*** Grade Report Program ***\n\n";
cout << "Enter data file name : ";
cin >> Filename;
cin.ignore(128, '\n');
SourceFile.open(Filename);
SourceFile >> Cols;
row = 0;
while (!SourceFile.eof() && row < MAX_ROWS)
{
for (col = 0; col < Cols; col++)
{
SourceFile >> Scores[row][col];
}
SourceFile >> Names[row];
row++;
Rows++;
}
SourceFile.close();
cout << "\nReading data ...\n\n Global Navigation\n Grade Report - Spring 2017\n Instructor : C. Columbus Section No. 1492\n\nName";
for (int ColNum = 0; ColNum <= Cols; ColNum++)
cout << "#" << ColNum << " ";
cout << "* Ave. Grade\n\n";
row = 0;
for (int PrintRow = 0; PrintRow <= Rows; PrintRow++)
{
cout << Names[PrintRow];
for (col = 0; col < Cols; col++)
{
cout << Scores[row][col] << " ";
}
row++;
cout << endl;
}
cin.get();
return 0;
}
Please?
>>60318186
>imblying that i will help somebody who didn't even bother making his code readable
kys
declare a gun and shoot yourself
>>60318024
/G/ hastags.
>>60318334
its not even that hard to read fuck off
>>60318849
>Please help me solve this problem
>FUCK YOU I'M NOT GOING TO MAKE IT EASILY PARSABLE FUCK OFF
You're not very good at asking for help.
>>60318024
>hey /g/ I need you to fix my homework that reads from a file
>I'm not going to give you the file format
>I'm not going to put my code in the provided code tags so it's fucking readable
>are you guys done doing my homework yet?
Consider suicide
>vir/g/ins can't fix an entry level CS program without demanding muh file type
lol just fucking look at the code
>>60318024
>PascalCase
>not camelCase
Usecode tags
>>60318024
If you want some help, make some effort so you can deserve it.
Put your code in some readable fashion.
>but how do i do it
Find out how by yourself.
>>60318024
Is it possible to get a file which has the format which you're trying to read and results in an error?
>>60318024
Oh I see first year exams are coming up and you are flunking, tough break kid but we're not allowed to help with your homework, take it over to >>>/wsr/
>>60318024
It's hard to tell without a file with the expected format but could it be possible that your file has a size larger than your max cols which is read inside the file? You do not perform any verification in that, let's say that the file includes a Cols with size 8 then you would access illegal spaces within the Scores array
>>60318024
RTFM
>>60318024
>Starting a variable with a capital letter
Literally end your life
>>60318024
Open a book, idiot
>>60318024
> that coding style
This is a troll.