home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19288 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  974 b 

  1. Path: sparky!uunet!noc.near.net!news.hi.com!calamari.hi.com!not-for-mail
  2. From: rogers@calamari.hi.com (Andrew Rogers)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with string processing.
  5. Date: 5 Jan 1993 23:26:08 -0000
  6. Organization: Hitachi Computer Products, OSSD division
  7. Lines: 15
  8. Message-ID: <1idn10INNpvg@calamari.hi.com>
  9. References: <1993Jan3.050935.1227@news2.cis.umn.edu> <Ts3TwB1w165w@wozzle.linet.org>
  10. NNTP-Posting-Host: calamari.hi.com
  11.  
  12. In article <Ts3TwB1w165w@wozzle.linet.org> alane@wozzle.linet.org (J. Alan Eldridge) writes:
  13. >>         char tmp[2] = {0};
  14. >>  
  15. >>         *tmp = ch;
  16. >>         strcat(str, tmp);
  17. >
  18. >tmp[0] has a 0 in it but tmp[1] is undefined. You are not creating
  19. >a nul-terminated string here.
  20.  
  21. tmp[1] most certainly does have a 0 in it; if the initialization list for
  22. an array contains fewer elements than the array itself, then the remaining
  23. array elements are initialized to 0.  Check the ANSI spec, or the relevant
  24. section in K&R.
  25.  
  26. AWR
  27.