home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5584 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  55 lines

  1. Path: news.brandonu.ca!menon
  2. From: menon@beijing.brandonu.ca
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: My code crashes my computer
  5. Date: 17 Mar 1996 09:29:41 GMT
  6. Organization: Brandon University
  7. Message-ID: <4igm25$poj@goofy.BrandonU.CA>
  8. NNTP-Posting-Host: beijing.brandonu.ca
  9. Originator: menon@beijing.brandonu.ca
  10.  
  11. This is an except from my program which shows where it crashes
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <math.h>
  17.  
  18. .
  19. .
  20. .
  21.  
  22. /***** READ_FILE *****/
  23. void read_file(char *infile, char *infile2){
  24.    int i=0, x, y, garb;
  25.    FILE *fp;
  26.    char *s="File Error";
  27.    char *comment="", buf;
  28.  
  29.    fp = fopen(infile, "r");
  30.    if (fp==NULL){
  31.          printf("FAILED!\n");
  32.       perror(s);
  33.          exit(1);
  34.          }
  35.    fgets(type,3,fp);
  36.    fscanf(fp,"%s",comment);
  37.    if (comment[0]=='#'){
  38.      do{
  39.         fscanf(fp, "%s",comment); 
  40.           sprintf(buf,"%d",atoi(comment));  <---Crashes Here
  41.           }
  42.      while (strcmp(comment,buf)); 
  43.  
  44. I compile it using:
  45. gcc -o corr corr.c -m68040 -m68881
  46.  
  47. If anyone can help me, I would greatly appreciate it.
  48.  
  49. -Vivek A. Menon
  50. -- 
  51. ____________________________________________________________________________
  52. Vivek A. Menon, B.Sc.                 4th year Comp.Sci./Geography
  53. menon@beijing.brandonu.ca            Brandon University
  54.                              Amiga 4000/040
  55.