I was looking how to write and read a file using C. After discovering that usign fopen("foo", "r+") or fopen("foo", "w+") it should be possible, I decided to create a dummy program just to try it. This is the program:
#include <stdio.h>
int main(){
char reader[81];
FILE *USE = fopen("dummy.txt", "w+");
fprintf(USE,"whatever \r\nhello");
while(fgets(reader, 80, USE)) {
printf("%s", reader);
}
fclose(USE);
return 0;
}
The idea was to create a new file called dummy.txt. Everytime this program is executed writes 2 lines in dummy.txt and then display those lines in the command line or terminal. As you can see it is not the most useful program ever but knowing how to do this can be very helpful in the future.
Any help is wellcome