Re: malloc
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Mon, 05 Oct 2009 00:43:59 +0000
In <4ac93e13$0$23741$bbae4d71@xxxxxxxxxxxxxxxxxxx>, Bill Cunningham
wrote:
I have never seen anyone declare anything of type size_t to pass
to
malloc but I have an example here. I used lcc this times and it had
fits with this code.
#include <stdio.h>
#include <stdlib.h>
main() {
char *man;
man=malloc(sizeof man);
You probably meant: man = malloc(sizeof *man); but what you have is
legal. Remember, though, that writing good C code isn't *only* about
writing legal C code.
free(man);}
Warning p.c: 4 no type specified. Defaulting to int
Use int main(void) to avoid this diagnostic message in future.
Error p.c: 7 found 'pointer to char' expected a function
I don't believe you. That is, I don't believe that what you've posted
is the same code that produced this diagnostic message.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
.
- Follow-Ups:
- Re: malloc
- From: Bill Cunningham
- Re: malloc
- References:
- malloc
- From: Bill Cunningham
- malloc
- Prev by Date: Re: dh, the daemon helper
- Next by Date: Re: malloc
- Previous by thread: malloc
- Next by thread: Re: malloc
- Index(es):
Relevant Pages
|