home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!auspex-gw!guy
- From: guy@Auspex.COM (Guy Harris)
- Newsgroups: comp.unix.programmer
- Subject: Re: I am stumped on this one!!!
- Message-ID: <13744@auspex-gw.auspex.com>
- Date: 26 Jul 92 02:14:54 GMT
- References: <1992Jul24.204944.18516@cbfsb.cb.att.com> <Brx394.4qL@undergrad.math.waterloo.edu>
- Sender: news@auspex-gw.auspex.com
- Organization: Auspex Systems, Santa Clara
- Lines: 18
- Nntp-Posting-Host: auspex.auspex.com
-
- >> cp_line = (char *)malloc(sizeof(strlen(pars_wbuf)));
- >
- > You're allocing the sizeof an int, which is likely four bytes.
- > You also forgot to alloc space for the '\0'. Try it again with:
- >
- > cp_line = (char*)malloc(sizeof(strlen(pars_wbuf) + 1));
-
- No, try it again with:
-
- > cp_line = (char*)malloc(strlen(pars_wbuf) + 1);
-
- because, as you noted, the "sizeof" doesn't belong there - it turns the
- argument into the size of the result of "strlen", which isn't the length
- of the string.
-
- (Also, try not leaving every single line of the original posting in your
- followup; it makes it rather hard to find the stuff that *doesn't* come
- from the original posting....)
-