954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

rewind

hi
if you use

rewind( FILE *in);

what you can use for

I/O stream library
ifstream in(ff.txt);
masa
Light Poster
29 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

hi if you use

rewind( FILE *in);


We don't use this...we use

rewind(in);

what you can use for

I/O stream library
ifstream in(ff.txt);


Are you sure about what you are asking...if yes, please make it more clear

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

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
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Hi
thank you for your reply, you are right I found what I am asking about.leave it.
one thing, if you define a file like this

char filename[20]="hi.txt";
FILE *fp;
	
	/*Open input file*/
	fp = fopen(filename,"r");
	if (fp != NULL)
	{
		 fprintf(stderr,"Could open input file.\n");
	}
	else
	{
		fprintf(stderr,"Could not open input file.\n");
		result = -1;
	}

now fp suppose to carry the filename, am I right?
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.
it seems a silly question, but I my brain froozen

masa
Light Poster
29 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

I would recommend you to read this tutorial
http://www.cprogramming.com/tutorial/cfileio.html

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 
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
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

thank you all I got it. solved

masa
Light Poster
29 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You