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

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!Sirius.dfn.de!Urmel.Informatik.RWTH-Aachen.DE!infoac!siebeck
  3. From: siebeck@infoac.rmi.de (Wolfgang Siebeck )
  4. Subject: Re: I am stumped on this one!!!
  5. Message-ID: <1992Jul25.165451.21726@infoac.rmi.de>
  6. Organization: RMI Net INFO.box Systems * Aachen * Hamburg * Flensburg
  7. References: <1992Jul24.204944.18516@cbfsb.cb.att.com> <Brx394.4qL@undergrad.math.waterloo.edu>
  8. Date: Sat, 25 Jul 1992 16:54:51 GMT
  9. Lines: 27
  10.  
  11. bbobak@undergrad.math.waterloo.edu (Brad Bobak) writes:
  12.  
  13. >In article <1992Jul24.204944.18516@cbfsb.cb.att.com> rajeev@cbnewsf.cb.att.com (rajeev.dolas) writes:
  14. >>
  15. >>Hello all,
  16. >>
  17. >>        pbuf = pars_wbuf;
  18. >>        cp_line = (char *)malloc(sizeof(strlen(pars_wbuf)));
  19.  
  20.  
  21. > You're allocing the sizeof an int, which is likely four bytes.
  22. > You also forgot to alloc space for the '\0'. Try it again with:
  23.  
  24. >    cp_line = (char*)malloc(sizeof(strlen(pars_wbuf) + 1));
  25.  
  26. or better:
  27.  
  28.     cp_line = (char*)malloc(strlen(pars_wbuf) + 1);
  29.  
  30.  
  31. >>        strcpy(cp_line, "\0");
  32. >>        tmp_line = cp_line;
  33.  
  34. -ws
  35. --
  36. siebeck@infoac.rmi.de (Wolfgang Siebeck)
  37.  
  38.