> rewind<STDIO.H> ~ Online tutorial

rewind



rewind                          <STDIO.H>

 Repositions file pointer to stream's beginning

 Declaration:  


void rewind(FILE *stream);


 Remarks:


rewind(stream) is equivalent to

  fseek(stream, 0L, SEEK_SET)

except that rewind clears the end-of-file and error indicators, while fseek
only clears the end-of-file indicator.

After rewind, the next operation on an update file can be either input or
output.

 Return Value:
  None


 Example:

 #include <stdio.h>
 #include <dir.h>

 int main(void)
 {
    FILE *fp;
    char *fname = "TXXXXXX", *newname, first;

    newname = mktemp(fname);
    fp = fopen(newname,"w+");
    fprintf(fp,"abcdefghijklmnopqrstuvwxyz");
    rewind(fp);
    fscanf(fp,"%c",&first);
    printf("The first character is: %c\n",first);
    fclose(fp);
    remove(newname);

    return 0;
}

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: