[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

help /g/

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 18
Thread images: 3

File: fuck_me.jpg (35KB, 535x577px) Image search: [Google]
fuck_me.jpg
35KB, 535x577px
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/ has
 tags.
>>
>>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

Use
code tags
>>
File: 1484611451585.png (241KB, 256x465px) Image search: [Google]
1484611451585.png
241KB, 256x465px
>>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
>>
File: 1478712605019.png (62KB, 373x380px) Image search: [Google]
1478712605019.png
62KB, 373x380px
>>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.
Thread posts: 18
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.