




|
User Profile
MOVIES
MUSIC
BOOKS
DRINKAGE
INSPIRATIONS
Blog
How unrealistic can you get
Blog Code
I quote (with my diatribes in parens): |
Gamer Profile
Poll
What part of games do you feel most important? |









User Comments!
ɤHAL
The Cake Is A Lie
-HAL
ʊCoolhand2
Kills People While They Type
Awwwwww.
Remember, the answer is always 42.
ʊchalkley3
I go where I please, and I please where I go
Prince Phillp to a Nigerian diplomat in traditional Nigerian garb: "You look as if you’re ready for bed."
ʊCoolhand2
Kills People While They Type
Remember, the answer is always 42.
ʊchalkley3
I go where I please, and I please where I go
Prince Phillp to a Nigerian diplomat in traditional Nigerian garb: "You look as if you’re ready for bed."
ӝrotane
Modder
>:]
ʊCoolhand2
Kills People While They Type
The functions you'll need to look up are fopen, fread, fwrite, fgetc, fputc, and fclose. They all use the FILE pointer type (which is built into C) except for fgetc and fputc.
A sample program would be something like:
#include <stdio.h>
int main( void )
{
/* The file handler pointer */
FILE *fhp;
/* The buffer we'll read the file into */
char[80] str;
int i; /*You'll see this used in a bit*/
/* Open up a random file in read-only mode */
fhp = fopen( "random.file", "r" );
fread( str, 1, 80, fhp );
/* Alternative way:
* Uses a counter. Though be careful with
* this, as it waits for EOF from the file
* before it stops, and that could lead to
* a buffer overflow problem. If done
* correctly, you can still do this though.
* for( i = 0; str = fgetc( fhp ); i++ );
*/
/* This writes to a file if you want to
* There are two ways to do this:
* for( i = 0; str && fputc( str, fhp ); i++ );
* and
* fwrite( str, 1, 80, fhp );
*/
/* And now we close the file */
fclose( fhp );
}
For details on the functions I used, you can start here: http://www.cppreference.com/stdio/fopen.html
Remember, the answer is always 42.
¤Irishancest
Legally Certified Warthog Operator
Beware. The Internewt is real!
I'll have a loil, on the rocks.