home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 14285 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  1.0 KB

  1. Path: sparky!uunet!ogicse!uwm.edu!cs.utexas.edu!natinst.com!stepan
  2. From: stepan@natinst.com (Stepan Riha)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Help w/files needed...
  5. Message-ID: <1992Aug20.205546.22434@natinst.com>
  6. Date: 20 Aug 92 20:55:46 GMT
  7. Article-I.D.: natinst.1992Aug20.205546.22434
  8. References: <l-hyzaq@rpi.edu> <1992Aug20.153053.26419@cgrg.ohio-state.edu>
  9. Sender: news@natinst.com
  10. Distribution: usa
  11. Organization: National Instruments, Austin, TX
  12. Lines: 16
  13. Nntp-Posting-Host: falcon.natinst.com
  14.  
  15. Description on how to use fopen with SFGetFile (rather neat) ...
  16. ...
  17. >    SFGetFile(SFGWhere,NIL,NIL,1,MyTypes,NIL,&reply);
  18. >    if (!reply.good) return;
  19. >    SetVol(0L, reply.vRefNum);
  20. >    strcpy(inFileName,reply.fName);
  21. >    PtoCstr(inFileName);
  22. >    inp = fopen(inFileName,"r");
  23. ...
  24. I don't believe reply.fName is 0 terminated, so the first strcpy is dangerous.
  25. Rather, call PtoCStr(reply.fName);
  26. Then you can safely do the strcpy(inFileName,reply.fName) or simply use
  27. reply.fName instead of inFileName.
  28.  
  29. -- 
  30.    Stepan Riha -- stepan@natinst.com
  31.