input file doesn't work correctly


i had this entirely wrong.... back to drawing board and thanks
Last edited on
seriously no one can help with this????
anyone?
last try
Is it possible to use stl container (such as vector)? if not you indeed need to count the lines (use std::geline()). Then allocate the array dynamically and then read it again to that array. The array is required to sort the names afterward.
i found out what I was doing was entirely wrong. Not to use strcpy... i was over thinking... students this is an example of what not to do.... don't even look at this for your work.
students this is an example of what not to do.... don't even look at this for your work.


How can we use it as an example if you delete your post.

grumble grumble grumble....

How can we use it as an example if you delete your post.


Here it is :p

C++ Convert program to input from file C++ Class?
A teacher has asked all her students to line up single file alphabetically according to their first name. For example, in one class Amy will be at the front of the line and Yolanda will be at the end. Write a program that prompts the user to enter the number of students in the class, then loops to read in that many names. Once all the names have been read in it reports which student would be at the front of the line and which one would be at the end of the line. You many assume that no two students have the same name. Validation: Do not accept a number less than 1 or greater than 25 for the number of students. http://pastebin.com/raw.php?i=BJYVWy6N This works correctly.

**** Part two re-write the file get names from a file instead of inputting them one by one. Names should read until there is no more data to read (instead of 1-25).

http://pastebin.com/95sNdjeD This is what I have so far. I'm not sure if I even need a count for it to work, I'm really stuck. I've even tried infile and testing it. I'm aggravated because we haven't covered this, nor is there much in the book, and my teacher has assigned it anyways.

Here is the text file info for easy testing. http://pastebin.com/raw.php?i=msS6fYH9

I need help with part two only.....
I need someone to compile and test if they can get a correct output and find where the error is and quote the error in code with the fix?

I can paste the code, but since this is common homework for C++ I figured it'd be better in pastebin with and expiration date.




***** Also, The more I read the question now I am even more confused. My assumption was that the 2nd part should still display the first (Amy) and last (Yolanda) but pull it from a file instead of user input.

Names should read until there is no more data to read. Does this mean she wants the program to display the entire list of names? I can do that...

I have fried my brain on this stupid problem..... If none of this makes sense it's my delirium...

Last edited on
Topic archived. No new replies allowed.