HELP!!! Vectors Display Student Records

Don't double-post. You're wasting people's time.

http://www.cplusplus.com/forum/beginner/248956/
Last edited on
Oops, sorry @helios. I just deleted the other one, so your link is dead.

And I notice that you've been "reported"! WTF?!

@Kat21909, edit your post and put your code in [code] tags so humans can read it.
Last edited on
Hello Kat21909,

Here are some tips to help you:


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

It makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.


Your use of blank lines is a good start, but you have to many where you do not need them and none where you do. As an example the struct would look better as:
1
2
3
4
5
6
7
8
9
10
struct student
{
	string Fname;
	string Lname;
	string ID;
	string Email;
	string Exam1;
	string Exam2;
	string Exam3;
}s;

And in "main" these lines would look better as:
1
2
3
4
5
6
7
8
    fstream inFile("inData.csv");
    ofstream outFile("outData.csv");
    if(!inFile.is_open())
// ------------------------------------
    fstream inFile("inData.csv");
    ofstream outFile("outData.csv");

    if(!inFile.is_open())

It just breaks thing up into parts that are more readable.

Regular variable names generally start with a lower case letter and camelCase is most often used in names. So your "Fname" would be "fName".

The line if(!inFile.is_open()) can be shortened to just if(!inFile). It does the same thing and you might consider the code:
1
2
3
4
5
6
7
8
9
10
std::string inFileName{ "" };  // <--- Put full file name here.

std::ifstream inFile("inFileName");

if (!inFile)
{
	std::cout << "\n File " << inFileName << " did not open" << std::endl;
	std::this_thread::sleep_for(std::chrono::seconds(5));  // <--- Needs header files chrono" and "thread".
	return 1;  //exit(1);  // Use the "exit" if not in "main", i.e., another file.
}

Line 8 is optional. I use this to keep the console window open long enough to read the message before the return closes the window. You may not need this line. The return will exit the program because there is no reason to continue until you fix the problem. Otherwise you would not be able to read anything from the file because the stream is not connected to the file. The only part to deal with is the number in the parentheses which is the whole number of seconds it will wait until the program continues.

The same concept can be used for the output file stream.

The first while loop condition based on checking for "eof" will not work the way you expect. Checking for "eof" in the while condition usually means that you will process the last read twice. This is most likely why you have the line
if (inFile.eof() ) break;, but it is in the wrong place to be useful. it should be after the first getline which is the first read of the file that could set "eof".

This is most often used to read a file of unknown length:
1
2
3
4
5
6
7
8
while (getline(inFile, Fname, ','))
{
	getline(inFile, Lname, ',');
	getline(inFile, ID, ',');
	getline(inFile, Email, ',');
	getline(inFile, Exam1, ',');
	getline(inFile, Exam2, ',');
	getline(inFile, Exam3, '\n');

This way when the getline fails to read anything "eof" is set and the while condition becomes false, so the while loop fails and the next line after the while loop is executed.

Another thing you could do is read directly into the struct then push it into the vector. This would eliminate seven lines of variables and seven lines of code following your getlines(). For the lines that start "outFile" use the struct variables before you read the next record.

Your menu is OK, but if something would go wrong, say entering a letter either by choice or by accident there is no way to deal with the problem. Trying to enter a letter into a numeric variable will cause "cin" to fail and become unusable until it is reset. When it comes to a menu I like to put this in a function and use a do/while loop to keep the menu going checking the input and only returning a valid choice.

The last thing I see is that you are trying to close your files inside the switch. Because of the break statements these lines will never be reached. They should be done outside the switch and outside the final while loop.

All that said are you asking if the program follows the instructions? For now I thin your code covers most of the instructions. I will know more once I get the program loaded and compiled.

One last note: your program uses an input file. Posting the input file or at least a useful sample of the file is most helpful. This way everyone will be using the same information.

Hope that helps,

Andy
I take the time to write something and come back to find the original post gone. What's up with that?

Guess this might help:
This account has limited functionality.
This was likely due to the user being reported by not following some specific rules for a service in this website.
If you believe this to be an error, please use our Contact form

Hey guys,

Did any one happen to copy the original code? Just for fun I like to work with the code and see if I can get it to work and as a learning experience.

Andy
@Kitty21909, why didn't you just add code tags like I asked you to?
Post your code here if you want help.

Hi @Andy, don't help this person through PM. That's not how it's done. Don't reward them for bad behavior.
Last edited on
So you didn't read the guidelines before you posted?
Then someone asked you to add code tags and instead of asking about it you just deleted your post?
And now you're sniveling about it?
You're joking, right?

BTW, Andy likes doing other people's homework. Monitor your PM and I'm sure you'll get your answer.
Whatever. It's strange that you can babble about how nothing is ever your fault but you can't just post your code. I guess you're just special.
Last edited on
I've never reported anything. Now you are just lying. And I never threatened you, you pathetic little liar. It seems like you are threatening me, in fact. You are the bully here. Get over yourself. You're not as special as you think you are. Get a life? I'm just sitting here watching TV, if that okay with you. You are the one without a life. You keep coming back, sniveling, whimpering, presumably wetting your pants. Do you think that's pleasant for me? Bully!
Handy Andie wrote:
Guess this might help:


So what does it mean when their "account has limited functionality"? Does that meant they can't post? And do they get it when they've been reported - and when they have low posts?
The condition is something along those lines, yes.
I'm not exactly sure what's happening, clearly more than one post was deleted before I read this, but someone here clearly abused the Report function.
As far as I remember, the original post here had nothing inherently wrong with it. The only issue was that the user double-posted in another thread. The original poster didn't have limited functionality after the first post was removed, but got it after someone with higher permissions removed the 2nd post, making the end result be both of the user's thread topics disappear. The latter is the issue I have.

Even if the original post was just asking for help without showing any effort, that doesn't mean the post should be reported (chances are they just won't get help). Someone is making this place harder for beginners, which is unnecessary, especially for ones that at least posted their code, meaning they at least put some effort into their question.
Last edited on
Agreed. Whenever the report function is used for anything other than spam (just double-posting doesn't count as spam), it's almost certainly being misused.
Hmm is this forum moderated often though? I know that one time (last week) the forum broke in that all new posts didn't have a body (and were apparently posted in 1970 xD) but that was fixed and those new threads were deleted so that suggests that there is somebody maintaining the website. But at the same time there still are glitches like not being able to put code tags when you make a thread.

Is somebody looking into the reports? Can't be sure. But if the reports aren't moderated enough then that could be a big problem. Anybody (I don't know if it's anybody or whether it depends on post count or join date) could potentially stop new accounts from making any posts at all.

This forum needs more moderation and maintenance. Is what I feel. And also the forum is kind of broken in my phone in that when I type enough text it starts overflowing out of the box instead of scrolling. Not to mention the glitches like not being able to use coding tags when making a post.

And also,
How the heck does this forum have so much spam? It's just incredible. Every day there is one or the other spam post (luckily they're quickly deleted by somebody reporting).

I've never seen spam like this anywhere else. I have not even seen one spam post on other forums in fact. Why does this forum have so much spam?

There's so much spam that I had a thought that really all these spam are controlled by one person and this one person posts in various websites and gets paid by the advertisers.

But the english really vary a lot so that might not be it.

Are these spam posts not BOTS? I mean they have to be right.. I mean if it's one person, they must be really dumb and also dumb to not learn from their posts being immediately deleted.

If they are bots, they are dumb bots. Maybe they could have made the bots post 10 times at once so that their posts won't get deleted.

It's just so hard to make sense of this.
How the heck does this forum have so much spam?
It's a fairly visible forum with a lot of traffic maintained (in the sense of the forum software) and "moderated" by a single human being. It's not like no one has ever pointed out to Twicker that he should appoint some moderators, but here we are.

I doubt the spammers are bots, and obviously they're not just one person. There's people who get paid to post spam manually. Obviously it doesn't pay a lot, and they only get paid to post, not to ensure that the spam stays up, so they're not incentivized to spam smartly (beyond raw quantity).
Just posting a bunch of threads at a time woudn't cut it. If all your threads are reported they still get deleted even if not immediately.
Last edited on
If you're able to post the minimum requirement before somebody gets to report you, then you would have enough posts that your threads won't get deleted, right?

It'll have to wait for the admin to get to see the reports. Then if all spammers were to do that (post the requirement) then just one admin couldn't be in time to get rid of all posts immediately. I guess it doesn't matter though since we don't have that problem.

But I think and especially if there's only one person maintaining this entire website, that this forum should appoint moderators from the community like other forums do. There are many people here who have been here since 2007 that's a whopping 13 years and have contributed a lot of helpful posts.

An example could be that the moderator reviews posts that got reported or move threads. Maybe we could make it so that everybody can, if they really want to, review reported posts and notify if they see something wrong. So then it would be an even higher level of community moderation.

It's a big forum. One of the largest if not the largest (in terms of activity) C++ forum there is. So little improvements would help.

If the admin hadn't had to worry about moderating then it would ease off a lot of work from him.
The problem is that the forum software is custom. If Twicker doesn't implement those features, they don't exist.
Last edited on
Topic archived. No new replies allowed.