There is this thing that gives me headaches in C programming when I read from files.
I do not understand the difference between these two methods:
FILE *fd; fd=fopen(name,"r"); // "r" for reading from file, "w" for writing to file //"a" to edit the file
fd returns NULL if the file cannot be opened, right?
The second method I use:
int fd; fd=open(name,O_RDONLY);
fd will be -1 if an error occurs when opening the file.
Would anyone be kind enough to explain this to me? Thanks in advance:)
source share