home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18737 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.1 KB  |  30 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  3. From: brown@NCoast.ORG (Stan Brown)
  4. Subject: Re: argv[] as a general purpose 2D array
  5. Organization: Oak Road Systems, Cleveland Ohio USA
  6. Date: Mon, 21 Dec 1992 11:59:22 GMT
  7. Message-ID: <BzLyMz.MsD@NCoast.ORG>
  8. References: <BzKoLn.8BL@mccc.edu>
  9. Lines: 19
  10.  
  11. In article <BzKoLn.8BL@mccc.edu> pjh@mccc.edu (P. J. Holsberg) writes:
  12. >Exam question asked that if the name of the file was not typed on the
  13. >command line, the user should be prompted for it.  Most set up a char
  14. >array to hold the name of the file, and strcpy'd to it from argv[1] if
  15. >the name was in argv[1].
  16. >
  17. >One student decided to save some memory space and scanf'd the prompted
  18. >name directly to argv[1]!
  19. >
  20. >Are there any problems to that approach??
  21.  
  22. Is this a serious question?
  23.  
  24. Consider the situation where argument 1 is, say, 2 characters long and
  25. the user types in, say, 8 characters in response to the prompt.  If
  26. scanf-ing into argv[1], what do you think will happen?
  27. -- 
  28. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  29. Cleveland, Ohio, USA
  30.