home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3936 < prev    next >
Encoding:
Text File  |  1992-07-27  |  1.4 KB  |  41 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!walter!att!cbfsb!cbnewsf.cb.att.com!rajeev
  3. From: rajeev@cbnewsf.cb.att.com (rajeev.dolas)
  4. Subject: Re: I am stumped on this one!!!
  5. Message-ID: <1992Jul27.135350.5772@cbfsb.cb.att.com>
  6. Sender: news@cbfsb.cb.att.com
  7. Organization: AT&T
  8. References: <1992Jul24.204944.18516@cbfsb.cb.att.com> <Brx394.4qL@undergrad.math.waterloo.edu> <13744@auspex-gw.auspex.com>
  9. Distribution: usa
  10. Date: Mon, 27 Jul 1992 13:53:50 GMT
  11. Lines: 28
  12.  
  13. In article <13744@auspex-gw.auspex.com> guy@Auspex.COM (Guy Harris) writes:
  14. >>>        cp_line = (char *)malloc(sizeof(strlen(pars_wbuf)));
  15. >>
  16. >> You're allocing the sizeof an int, which is likely four bytes.
  17. >> You also forgot to alloc space for the '\0'. Try it again with:
  18. >>
  19. >>    cp_line = (char*)malloc(sizeof(strlen(pars_wbuf) + 1));
  20. >
  21. >No, try it again with:
  22. >
  23. >>    cp_line = (char*)malloc(strlen(pars_wbuf) + 1);
  24. >
  25. >because, as you noted, the "sizeof" doesn't belong there - it turns the
  26. >argument into the size of the result of "strlen", which isn't the length
  27. >of the string.
  28. >
  29. >(Also, try not leaving every single line of the original posting in your
  30. >followup; it makes it rather hard to find the stuff that *doesn't* come
  31. >from the original posting....)
  32.  
  33. I did modify my code and removed the sizeof(), but that does not help.
  34. As I mentioned previously, the error is in fputs() or putc().
  35.  
  36. Thanks.
  37.  
  38. Raj Dolas
  39.  
  40.  
  41.