rewind() does nothing more than seek to the beginnng of file. In C you can accomplish the same thing with fseek() function. In C++ fstream use seekg(0,ios_base::beg) or seekp(0,ios_base::beg)
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
now fp suppose to carry the filename, am I right?
Wrong. fp is a pointer to a structure that contains information about the file -- that structure does not contain the filename. Look in stdio.h and you can see what that structure contains, although you may not understand the purpose for all structure members.so if I used
cout << "the file name is "<< fp << endl;
is suppose to print the filename hi.txt , but actually it prints on screen 00478998.
why is that.
Because fp is not a pointer to the filename, but a pointer to FILE structure.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343