Mail Archives: djgpp/1997/10/28/18:03:52
At 12.40 1997-10-27 +0100, you wrote:
>Hello the world !
>
>I have a problem:
>How can I write a numeric value to the disk ?
>when I make:
>..
>FILE *disk;
>float i;
>
>...
>
>
>fputs(i,disk); IT DOESNT WORK CORRECTLY
>fclose(disk);
>
>
>How can I write a numeric value to the disk ?
Well, I don't know wether you want to store it as binary or text, i.e. if
you want to be able to open the file in a text-editor and read the value,
or if you just want to store it into the file as a binary number, which
would probably be the case if you only wanted to read it into your program
again.
Anyway, if you want to write it as text you could use several methods, for
an example:
fprintf(disk, "%g", i);
But if you want to store it as binary (make sure the file is opened in
binary mode) you would use:
fwrite(&i, sizeof(i), 1, disk);
I hope this helps.
-- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se --
*****************************************************
* A brief description of DJGPP: *
* NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! *
*****************************************************
- Raw text -