So yeah, SBPLI is tomorrow, still ironing the bugs out of that Dashboard I have :).
I think it’s working perfectly, except for one tiny error. After a seemingly random (although rather precise) number of loops, fopen just doesn’t work.
I have a line like this…
data = fopen(“data.txt”,“w”);
It’s supposed to open a string to a file, works great, most of the time. After a certain number of loops though, it stops working, until I restart my program. This takes no more than 30 seconds to pop up, unacceptable for a Dashboard (5 minutes would be, but less than two minutes, no).
So, my question is, what other way (besides fstream) is there to output to a file? I need something that’s rather generic and easy to implement, but at the moment, I’m open to any suggestions just so this thing will work. I’ll even try using fstream again, but that took so long to convert everything from fstream to stdlib.h…
Speedy answers make me happy, cause I don’t want to be up all night working on this :-p.
fopen opens a file for writing (in your case). You will only need to perform this once. To write a string into a file I would use fprintf(data,“Hello world”);.
At the end of your program use a fclose(data); to close the file and flush the buffers out.
In other words you need a fclose(data); command for every fopen command you have. An nether fopen nor fclose is writting any data to a file.
I just converted it all over to fstream (and learned a bit about vs.NET), so I think it’ll work like this for now. If I have any errors, I’ll come back and try that fflush thing, cause I was running out of memory, so I’d bet that’s the reason.
I can use fstream, I had just redone my program to get rid of it cause it was acting funny, but by rewriting all of that code it fixed whatever problems I was having. Plus, I have about 9 or 10 hours till I have to use the program, so simpler is better :-).