home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18578 < prev    next >
Encoding:
Text File  |  1993-01-12  |  2.0 KB  |  82 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!ufo!jato!jdickson
  3. From: jdickson@jato.jpl.nasa.gov (Jeff Dickson)
  4. Subject: Re: SEEKing to EOF
  5. Message-ID: <1993Jan12.181112.27235@jato.jpl.nasa.gov>
  6. Organization: Jet Propulsion Laboratory
  7. References: <paulm.02tb@pam-sy.UUCP>
  8. Date: Tue, 12 Jan 1993 18:11:12 GMT
  9. Lines: 71
  10.  
  11. In article <paulm.02tb@pam-sy.UUCP> paulm@pam-sy.UUCP (Paul C. Mrozowski) writes:
  12. >
  13. >  Hopefully someone here can answer a simple (?) question (or maybe just 
  14. >a dumb question). I'm writing a small program that's supposed to open
  15. >a file, read in some information, and write out this info. to a second
  16. >file (appending it to the second file). Everything seems to work, right
  17. >until I do the FPuts, then the program bombs. Here's some of the code:
  18. >
  19. >  (misc includes, and opening of both files).
  20. >
  21. >
  22. >
  23. >j = Seek(file_handle2, 0, OFFSET_END);     /* Move to the EOF() */
  24. >for( ; ; )
  25. >{
  26. >    
  27. >buffer = FGets(file_handle, line, NUM);
  28. >
  29. >    if(buffer == NULL)
  30. >    {
  31. >        Close(file_handle);    
  32. >                Close(file_handle2);  
  33. >        Exit(0);
  34. >    }
  35. >    
  36. >p = strstr(buffer,string);
  37. >
  38. >    if(p != NULL) break;
  39. >
  40. >}
  41. >
  42. >p=p+sizeof(string);
  43. >strcpy(newstr,"Rename ");
  44. >strcat(newstr, "1439");
  45. >strcat(newstr, p);
  46. >
  47. >printf(newstr);
  48. >i = FPuts(file_handle2, newstr);       /* Program bombs right here */
  49.  
  50. Are you sure? Aside from the fact that these two lines:
  51.  
  52.     p=p+sizeof(string);
  53.         and
  54.     strcat(newstr, p);
  55.  
  56. serve absolutely no purpose - your printf statement is not in the correct
  57. format.
  58.  
  59. It ought to be something like "printf("%s\n", newstr);"
  60.  
  61. >
  62. >
  63. >  I have a feeling I'm missing something obvious, but I'm not sure what.
  64. >Any suggestions?
  65. >
  66.  
  67.  
  68. >Paul
  69. >
  70. >-- 
  71. >
  72. >paulm%pam-sy%sycom@ilium.troy.msen.com
  73. >---
  74. >   Paul Mrozowski             |  "You can have anything you want but
  75. >   NetMail: paulm@pam-sy.uucp    |   you'd better not take it from me"-GNR
  76. >
  77. >     IBM Logic: "Keyboard Failure, press <F1> to continue..."
  78.  
  79. Jeff
  80.  
  81.