ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/10/19/09:48:18

Sender: <dafniotis AT chera6 DOT che DOT wisc DOT edu>
Date: Mon, 19 Oct 1992 08:17:11 CDT
From: Petros Dafniotis <dafniotis AT chera6 DOT che DOT wisc DOT edu>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: rewind(FILE *) does not work ...

The following file (test.c) demonstrates the problem I faced:

/* test.c */
#include <stdio.h>
#include <stdlib.h>

main()
{
  FILE *fp;
  int ch;

  if ((fp = fopen("C:\\SRC\\CC\\TEST.C", "r")) == NULL) {
    puts("\n\a\t\tError!\n");
    exit(1);
  }
  while ((ch = fgetc(fp)) != EOF)
    putchar(ch);
  puts("\nRewind\n");
  rewind(fp);

  while ((ch = fgetc(fp)) != EOF)
    putchar(ch);

  fclose(fp);
  puts("\n\tAll ok.\n");
  exit(0);
}


As you could see I should have the contents of TEST.C printed on my screen
twice. Well, it happens only once. Apparently rewind() fails. Also, in
<stdio.h>, I see the prototype:
int rewind(FILE *);
WHY? Shouldn't it be
void rewind(FILE *);
I thought that is what the standard says for the rewind()

Thanks for any help. By the way, the program works on SUN SPARCI with GCC v2.1,
VMS with C v3.2, and TC & BC on MS-DOS. I think it also fails with MSC v6.0
(I am not certain for the latter).

					Petros Dafniotis (AKA VMS4Ever)
					Graduate Student
					Chem Engr Dept, UW-Madison


+--------------------------------------------------------------------------+
| E-mail:  dafniotis AT chera1 DOT che DOT wisc DOT edu  | Petros Dafniotis               |
|          dafniotis AT che31a DOT che DOT wisc DOT edu  | Chem Engr Dept                 |
|           dafnioti AT cae DOT wisc DOT edu         | University Of Wisconsin-Madison|
+--------------------------------------------------------------------------+
|                            VAX + VMS  4  EVER!                           |
+--------------------------------------------------------------------------+

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019