I have a question regarding file pointers (i.e FILE *). I am having a hard time understanding conceptually what this represents in terms of its memory. When the concept of files was introduced in class, it was said that files are used so that we can store persistent data (i.e. data that will be lost even after closing our function). The way I comprehend that is that the usually when we run functions, we use the RAM to store memory. However, for files we will be storing the file data to the computers hard drive. Is my comprehension correct here?
Regarding file pointers: Are the file pointers storing the address of a FILE in the Hard drive? If so, do hard drives also have memory addressed based on hexadecimals? I am asking this because I just ran the following code:
int main(int argc, char *argv[])
{
FILE *file = fopen(argv[1], "r");
printf("%p", file);
}
and I got the following response printed:
~/ $ ./pset3b card.raw
0x1f4e260~/ $
Last question is an understanding of what a file pointer means in the context of a file that has been opened for reading? for example, in the following code, "file" seems to be storing an address. What is it storing an address of? If I were to deference "file", would I find the argv[1] file?
Thank you.
FILE *file = fopen(argv[1], "r");