| Showdon (39) | ||||
This is a copy of my teacher's program that won't run when I compile it. Help me fix it so that I can finish my homework.
| ||||
|
|
||||
| trynreadme (21) | ||
lol,
| ||
|
|
||
| Showdon (39) | |
| Kind of hard to do my homework if the teacher's example was wrong.... | |
|
|
|
| trynreadme (21) | |
|
what's the homework? Correct the program? | |
|
Last edited on
|
|
| Chervil (812) | |
|
It won't run for me because I don't have the input file "dropout115.txt". Do you have sample input data for testing purposes? | |
|
|
|
| Showdon (39) | |
|
35 4 42 4 27 3 36 5 | |
|
|
|
| Showdon (39) | |
| The program is to read the file dropout115.txt and display the information in a terminal console. The first number is the number of students (numStudents) and the 2nd number is the number of dropouts (numDropouts). | |
|
|
|
| trynreadme (21) | |
| looks like you don't have the file "dropout115.txt in the right location | |
|
|
|
| trynreadme (21) | ||
|
it's giving me the proper output, what are you using to compile? Well, when I ran it with "dropout115.txt" having no data, it returned the same values you are outputting. Once I put in the sample data
it gave me the correct output. | ||
|
Last edited on
|
||
| Showdon (39) | |
| I'm using codeblocks. I have the txt file in the same folder as the cpp file. Is that wrong, its worked for all my other programs. | |
|
|
|
| trynreadme (21) | |
well you're not triggering thecout << "The file could not be opened." << endl;so it seems like your file is opening, you have that sample data in the "dropout115.txt"? | |
|
|
|
| Showdon (39) | |
| yes, its just like it is on the first post. I am doing this in ubuntu. Could that have anything to do with it, I'm a new ubuntu user. | |
|
|
|
| Chervil (812) | |
|
If the file is in the wrong location, you will get the error message, "The file could not be opened." Perhaps there are several different copies of the input file, containing different data? With the correct file, the program works ok for me. | |
|
Last edited on
|
|
| Showdon (39) | |
| Nope I'm pretty sure I only put one txt file in the folder with it called dropout115. | |
|
|
|
| Showdon (39) | |
| Is anyone trying this on a linux based machine? | |
|
|
|
| trynreadme (21) | |||
|
I am now. Was doing it on a VM with Visual Studios and it worked great. I then tried it on Xcode on my Mac and found the possible issue. Put in the full location of the file "dropout115.txt". ie. "/Documents/Cpp/ReadFrom/dropout115.txt"
| |||
|
Last edited on
|
|||
| Showdon (39) | |
| Nope still getting the same output. | |
|
|
|
| trynreadme (21) | |
| k, I'm pulling up my Backtrack VM right now, going to put codeblocks on there and try it also, give me a few. | |
|
|
|
| Showdon (39) | |
| What does -nan mean? | |
|
|
|
| trynreadme (21) | |
| lol, I'm a bit of a Cpp newb, I have no idea. I just know that I got -nan as an output when I had no data in the "dropbout115.txt". | |
|
|
|