![]() |
|
#1
|
|||
|
|||
Re: using void functions; reading from fileCPP / C++ / C Code:
CPP / C++ / C Code:
Now look through your program. Think about where do the initial values of t1, t2 etc. change. More precisely, look at the values before and after the call to GetData(). I didn't look through the whole code, just about up to the call to GetData(). |
|
#2
|
|||
|
|||
using void functions; reading from filethe program i am compiling requires me to read from a file with student id's and their test 5 scores. here is a sample of the data in green:
123 90 98 80 79 70 there are 9 lines of data. i am supposed to use void functions to read and print the data from the file to another file, find each student's lowest test grade, find the average of the remaining test grades, total up the number of students, then find the average test grade for the students. This needs to be printed to another file "results" in a neat little table. i'm getting the table, but it's not coming out right. The program ignores the student id, then says everything else is 0. here is what the output looks like: 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 0 0 0 0 0 0.00 In a class of 9 the average test score was0.00. it does calculate the number of students correctly! i think it has something to do with my function GetData. i don't think this is the correct way to retrieve the info from the file, but i'm not sure of another way. i have tried to use the getline function to get the string studentID, but i think that takes the entire line and considers all of those numbers a studentID. and then i can't use get(studentID) because it's not a character. is there another way i can retrieve the info? the compiler gives me a warning that t1, t2, etc are not initialized.... i think it all has to tie in with GetData. sorry i've written a book, but i know that you who are looking at this want some background to go off of. thanks for any advice! CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
Re: using void functions; reading from fileAfter your call to GetData(), try displaying the data to the screen to see if the function worked.
__________________
Age is unimportant -- except in cheese |
|
#4
|
|||
|
|||
Re: using void functions; reading from fileah. so my problem is that i didn't really understand reference variables. when i change the parameters to (string&, int&,...) etc. the program works, because i am changing the value of the variable in the function (at least, i think i know what i am talking about!).
thanks Walt P and Kimmo for your advice. |
|
#5
|
|||
|
|||
Re: using void functions; reading from fileQuote:
CPP / C++ / C Code:
Output: Code:
|
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Linked Lists advice request | promsan | C Programming Language | 74 | 23-May-2007 08:29 |
| triangle (polygon), drawing, sizing, and rotation programme using linked lists... | promsan | C Programming Language | 12 | 14-May-2007 14:03 |
| need help with a console menu system | BullBuchanan | C++ Forum | 6 | 20-Aug-2006 14:46 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The