home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / msdos / programm / 3283 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.8 KB  |  38 lines

  1. Newsgroups: alt.msdos.programmer
  2. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!batcomputer!caen!sdd.hp.com!usc!howland.reston.ans.net!spool.mu.edu!agate!netsys!ukma!news!news.cs.odu.edu!wiggins
  3. From: wiggins@sirocco.cs.odu.edu (Samuel E Wiggins)
  4. Subject: question about compiling TC++
  5. Message-ID: <WIGGINS.93Jan28142329@sirocco.cs.odu.edu>
  6. Sender: news@cs.odu.edu (News File Owner)
  7. Nntp-Posting-Host: sirocco.cs.odu.edu
  8. Organization: Old Dominion University, Norfolk, VA, USA
  9. Date: Thu, 28 Jan 1993 19:23:28 GMT
  10. Lines: 26
  11.  
  12. I'm new to writing programs for IBM PC's with Turbo C++, so please bear with
  13. me.  I'm in the initial stages of writing a program.  So far, I've only made a
  14. a main function that calls this other function which is in another file.  What
  15. The main module doesn't do anything but call the other.  It's got like all of
  16. 5 lines of source code so far.  The module it calls, though, uses stdio.h,
  17. string.h, and conio.h for a bunch of gets() operations to input some things.
  18. That's basically all these do.
  19.  
  20. My question is, how come it only works when I compile with the compact or
  21. larger models?  For example, for this code:
  22.     char *s;
  23.     gets(s);
  24.     printf("S is: %s\n",s);
  25. The last time a gets() is run, it'll print that:
  26.     S is: (null)
  27. no matter what you type in.  BTW, the code is EXACTLY this way.  The stuff
  28. typed in gets lost by the gets() by the time the next line is run. ???
  29. UNLESS, I compile with the compact or larger model in TC++, in which case the
  30. problem disappears, WITHOUT touching the code.  Now, I know all
  31. this probably has to do with the amount of memory set aside to allocate
  32. all the variables and other stuff, but it's a relatively simple program.
  33. Sheesh!  Does it take all this memory and stuff?
  34.  
  35. Could someone knowledgable please respond?
  36.  
  37.  
  38.