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