answersLogoWhite

0

How files are created and used in c?

User Avatar

Anonymous

15y ago
Updated: 8/17/2019

Files are created and used in C with the stdio library functions fopen, fread, fwrite, fprintf, fscanf, fclose, etc. A trivial example that writes one line to a file...

FILE *file;

file = fopen ("somefile.txt");

if (file == null) { ... error code ... } else

fprintf (file, "This is a line of data in a file\n");

fclose (file);

}

This will create and write a standard "text" file that can be subsequently opened with a standard text editor such as notepad (windows) or vi (unix).

User Avatar

Wiki User

15y ago

What else can I help you with?