pFile = fopen ("myfile.txt",w)

Mar 14, 2013 at 1:23am
1
2
FILE * pFile;
pFile = fopen ("myfile.txt",w)


I wonder what will be assigned to pFile? an address of ?
if "myfile.txt" is string is it
string is also an array
so array address will be assigned to pFile?

I did go thru pointer chapter.
pointer = store address of another variable.
So at the above case I wonder what pFile is storing ?
Last edited on Mar 14, 2013 at 1:24am
Mar 14, 2013 at 1:38am
So at the above case I wonder what pFile is storing ?


The variable that pFile points to is a 'FILE' struct. This struct contains information about the opened file and possibly some callbacks for i/o.

The 'FILE' struct is abstract, so you should not worry about the specifics. You don't need to know exactly what it contains, you should only know what its purpose is.
Last edited on Mar 14, 2013 at 1:38am
Mar 14, 2013 at 1:38am
fopen return a pointer to a stream.
http://www.cplusplus.com/reference/cstdio/FILE/

[FILE] object type that identifies a stream and contains the information needed to control it, including a pointer to its buffer, its position indicator and all its state indicators.

The content of a FILE object is not meant to be accessed from outside the functions of the <cstdio> and <cwchar> headers;
.

Topic archived. No new replies allowed.