home *** CD-ROM | disk | FTP | other *** search
- Path: comma.rhein.de!serpens!not-for-mail
- From: mlelstv@serpens.rhein.de (Michael van Elst)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: My code crashes my computer
- Date: 17 Mar 1996 13:39:44 +0100
- Organization: dis-
- Message-ID: <4ih16g$dol@serpens.rhein.de>
- References: <4igm25$poj@goofy.BrandonU.CA>
- NNTP-Posting-Host: serpens.rhein.de
-
- menon@beijing.brandonu.ca writes:
-
- >void read_file(char *infile, char *infile2){
- > int i=0, x, y, garb;
- > FILE *fp;
- > char *s="File Error";
- > char *comment="", buf;
-
- > fp = fopen(infile, "r");
- > if (fp==NULL){
- > printf("FAILED!\n");
- > perror(s);
- > exit(1);
- > }
- > fgets(type,3,fp);
-
- your compiler should complain about an error here.
-
- > fscanf(fp,"%s",comment);
- > if (comment[0]=='#'){
- > do{
- > fscanf(fp, "%s",comment);
- > sprintf(buf,"%d",atoi(comment)); <---Crashes Here
-
- obviously. sprintf awaits a pointer to a character array and not
- an uninitialized character variable. Your compile should complain
- here too.
-
- >I compile it using:
- >gcc -o corr corr.c -m68040 -m68881
-
- >If anyone can help me, I would greatly appreciate it.
-
- Compile with -Wall to get some tons of warnings from your compiler.
-
-
- --
- Michael van Elst
-
- Internet: mlelstv@serpens.rhein.de
- "A potential Snark may lurk in every tree."
-