for my homework assignment I’m asked to get data from an input file, and then put it in an output file.
simple, but there’s one more thing:
“do not store the information from the file inside the program. If necessary, read the file multiple times.”
Now, correct me if I’m wrong but whenever you use a fgets, fscanf etc I would have to store it somewhere, right?
Or is there a way I could get the data and put it directly into the output file?
My thinking is that the homework assignment is probably referring to storing all the data (as opposed to just something temporary for each scanned lined), because we’re also asked to sort the output, so some people may try putting everything and sorting it in the program.
[whisper]this should probably go into computer & games, but it’s kinda urgent and more people read random =P. If this shouldn’t be here, please feel free to move it[/whisper]
Don’t think I can call fgets without specifying the string pointer argument.
[quote=λ]More seriously, why don’t you ask your teacher what it means? That’s what I’d do…[/quote]Interesting method you got there, but don’t think I’ve learnt that yet so it’ll take me a few more minutes to understand what you’re doing… but anyway, to answer your question:
My assignment is due in 4 hours, and it’s a Sunday night I just realized this little tricky line they threw into the instructions.
edit: Ah I see what you’re doing:trout:. Nope, I dont think my prof would allow that to slide… after all, I should have clarified with her earlier
njs I need to the output file sorted… so that wouldn’t be enough :-/
I managed to get everything done, except that for some reason stdio.h does not seem to have popen and pclose, and I need those in order to print the date in my file too! Bah.
oh I know I could use time.h, but the date printed in the assignment example is in the format of when you use the “date” command.
that however, seems to only work if I were copying the file character for character. This isn’t all that I’m supposed to do… I need the output file sorted.
The input file contains a name and a year, and I’m supposed to sort them by the year.
This would be another problem … how would I make a comparison without temporarily storing at least 1 value?
edit: hm wait, I think that’s possible…just gonna get ugly.
I managed to carry out comparison by directly comparing fgetc(infile) and fgetc(outfile).
I still have yet to figure out another problem that came from that, though, but it’s rather hard to type it out because I myself am confused and not sure where the problem is.
njs, interesting. I don’t know if I’m allowed to do that, heh. I’ll have to give that a shot.