Re: malloc



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
.



Relevant Pages

  • qualified pointer problem
    ... Since lcc preserves qualifiers in evaluating expressions (it strips ... In several places, however, lcc does. ... If l->type is a qualified pointer type, isptrsays it ia s pointer ... extern struct tag {int mem;} *x; ...
    (comp.compilers.lcc)
  • Re: Strategy to implement 64-bit contants for lcc
    ... Obviously each operation will have to be added to simplify. ... In lcc 3.6 each of the basic types like char, short, int unsigned int, ... In lcc 4.2 the basic types share only two operator codes namely INT ... typedef union value { ...
    (comp.compilers.lcc)
  • Re: Is this an error or undefined behaviour?
    ... int x; ... I would say that the behavior is undefined, because the standard fails to say what an expression involving a VLA means when the VLA hasn't actually been created. ... ifgoto label; ... My understanding is that the program's output is acceptable, but that the diagnostic message needs some improvement. ...
    (comp.lang.c)
  • Re: New to C programming. Signed up for a class at Junior college
    ... Expected double got int" ... output specifier (unless this is some sort of non-standard ... extension in lcc). ... You don't want to start off learning non-standard ...
    (comp.compilers.lcc)
  • Re: Strategy to implement 64-bit contants for lcc
    ... I do have a long long type just like the one in lcc 4.2. ... In lcc 3.6 each of the basic types like char, short, int unsigned int, ... typedef union value { ... The new version 4.2 is using conditional statements ...
    (comp.compilers.lcc)