fp = fopen("/tmp/test.txt", "w+"); code example
Example 1: fp = fopen("/tmp/test.txt", "w+");
// C - Used to write into a file line by line from user input
#include <stdio.h>
main()
{
FILE *fp;
char buffer[20];
fp = fopen("/tmp/test.txt", "r");
fscanf(fp, "%s", buffer);
printf("Read Buffer: %s\n", %buffer );
fclose(fp;);
}
Example 2: fp = fopen("/tmp/test.txt", "w+");
// C - Used to write into a file
#include <stdio.h>
main()
{
FILE *fp;
fp = fopen("/tmp/test.txt", "w");
fprintf(fp, "This is testing...\n");
fclose(fp;);
}