cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/07/21:30:26

From: l8a AT swbell DOT net (Larry Ochoa)
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with DJGPP
Message-ID: <MPG.105e4129bf125abf989680@news.swbell.net>
Organization: Fuzz Ware
Lines: 49
Date: Mon, 7 Sep 1998 20:15:22 -0500
NNTP-Posting-Host: 207.193.31.160
NNTP-Posting-Date: Mon, 07 Sep 1998 20:18:38 CDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi, 
  When I try to compile the following program:

#include <stdio.h>
#include <stdlib.h>

main(void)
{
  FILE *file;
  char name[]= "file.txt";
  char blah[5];
  enum {success, fail};
  int i, f_s = success;

  if ((file = fopen(name, "w+")) == NULL) {
    printf("Cannot open %s.\n", name);
    f_s = fail;
  } else {
    for(i=1;i<=100;i++) {
      fprintf(file,"%d\n",i);
      fgets(blah, 5, file);
      printf("%s\n", blah);
    }
  }
  fclose(file);
  return f_s;
}


with djgpp, something happens to "file.txt". Instead of just putting the 
number like this:

1
2
3
4

I get this(file is attached):

1
¼ €2
„±  3
h`< 4

Why? What did I do wrong?

Thanks,
Syco
Larry Ochoa

- Raw text -


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