C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-26-2002, 06:16 AM   #1
Unregistered
Guest
 
Posts: n/a
Cool writing contents of array to file

fprintf(string, "%f", array[0]);

That statement above writes to a data file but stops after about a hundreds line are written. The data that is stored in array[0] is created as the file is being written (dynamically??)

How do I code so that I can continously write to a file as the data is being created?

Thanks,

Donald
  Reply With Quote
Old 06-26-2002, 06:34 AM   #2
Unregistered
Guest
 
Posts: n/a
Thumbs up

sprintf(string, " %g", draw_geom_buf.value[0]);
fprintf(output,"%s\n",string);

this the actual code sorry.

Donald
  Reply With Quote
Old 06-26-2002, 11:12 AM   #3
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,676
> How do I code so that I can continously write to a file as the data is being created
Can you explain how this is being achieved?

In a single thread, you're either modifying the array or writing to the file.
Salem is offline   Reply With Quote
Old 06-26-2002, 12:40 PM   #4
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
Re: writing contents of array to file

Quote:
Originally posted by Unregistered
How do I code so that I can continously write to a file as the data is being created?
Where is the input coming from? You need to control the input loop somehow. Bit difficult to advise without seeing more code really.
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Old 06-26-2002, 04:06 PM   #5
Unregistered
Guest
 
Posts: n/a
Talking

I have it. I forgot to fclose(output); this flushes all the data created during the execution of the main program to the output file after the main program is exited.

The data is basically written to the file during the execution of the program then when you exit the program the rest of the data stored in the array is flushed out to the data file.

Without fclose() the rest of the data that is stored in the array is not written to the data file, resulting in a inacurate data file.

Once again fclose() saves the day.
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A development process Noir C Programming 32 12-19-2009 10:15 AM
File Writing Problem polskash C Programming 3 02-13-2009 10:47 AM
opening empty file causes access violation trevordunstan C Programming 10 10-21-2008 11:19 PM
Basic text file encoder Abda92 C Programming 15 05-22-2007 01:19 PM
Struct *** initialization Saravanan C Programming 20 10-09-2003 12:04 PM


All times are GMT -6. The time now is 03:04 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22