home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!ufo!jato!jdickson
- From: jdickson@jato.jpl.nasa.gov (Jeff Dickson)
- Subject: Re: SEEKing to EOF
- Message-ID: <1993Jan12.181112.27235@jato.jpl.nasa.gov>
- Organization: Jet Propulsion Laboratory
- References: <paulm.02tb@pam-sy.UUCP>
- Date: Tue, 12 Jan 1993 18:11:12 GMT
- Lines: 71
-
- In article <paulm.02tb@pam-sy.UUCP> paulm@pam-sy.UUCP (Paul C. Mrozowski) writes:
- >
- > Hopefully someone here can answer a simple (?) question (or maybe just
- >a dumb question). I'm writing a small program that's supposed to open
- >a file, read in some information, and write out this info. to a second
- >file (appending it to the second file). Everything seems to work, right
- >until I do the FPuts, then the program bombs. Here's some of the code:
- >
- > (misc includes, and opening of both files).
- >
- >
- >
- >j = Seek(file_handle2, 0, OFFSET_END); /* Move to the EOF() */
- >for( ; ; )
- >{
- >
- >buffer = FGets(file_handle, line, NUM);
- >
- > if(buffer == NULL)
- > {
- > Close(file_handle);
- > Close(file_handle2);
- > Exit(0);
- > }
- >
- >p = strstr(buffer,string);
- >
- > if(p != NULL) break;
- >
- >}
- >
- >p=p+sizeof(string);
- >strcpy(newstr,"Rename ");
- >strcat(newstr, "1439");
- >strcat(newstr, p);
- >
- >printf(newstr);
- >i = FPuts(file_handle2, newstr); /* Program bombs right here */
-
- Are you sure? Aside from the fact that these two lines:
-
- p=p+sizeof(string);
- and
- strcat(newstr, p);
-
- serve absolutely no purpose - your printf statement is not in the correct
- format.
-
- It ought to be something like "printf("%s\n", newstr);"
-
- >
- >
- > I have a feeling I'm missing something obvious, but I'm not sure what.
- >Any suggestions?
- >
-
-
- >
- >Paul
- >
- >--
- >
- >paulm%pam-sy%sycom@ilium.troy.msen.com
- >---
- > Paul Mrozowski | "You can have anything you want but
- > NetMail: paulm@pam-sy.uucp | you'd better not take it from me"-GNR
- >
- > IBM Logic: "Keyboard Failure, press <F1> to continue..."
-
- Jeff
-
-