User forums > Embedded development
What code is it used to read & write text files in C?
(1/1)
cesar7160:
What code is it used to create, read & write text files in C?
Where can i find a tutorial or a guide?
cesar7160:
I found it, here it is:
#include <stdio.h>
int main ( void )
{
static const char filename[] = "file.txt";
FILE *file = fopen ( filename, "r" );
if ( file != NULL )
{
char line [ 128 ]; /* or other suitable maximum line size */
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
fputs ( line, stdout ); /* write the line */
}
fclose ( file );
}
else
{
perror ( filename ); /* why didn't the file open? */
}
return 0;
}
ollydbg:
Off topic here... :shock:
Take care for being locked.
Jenna:
--- Quote from: ollydbg on May 20, 2009, 05:46:21 pm ---Off topic here... :shock:
Take care for being locked.
--- End quote ---
Locked !
Navigation
[0] Message Index
Go to full version