Re: C or C++ for FOSS/linux?



Chris F.A. Johnson <cfajohnson@xxxxxxxxx> typed

On 2006-12-29, Sebastian 'lunar' Wiesner wrote:
Jan Panteltje <pNaonStpealmtje@xxxxxxxxx> typed

[snip]

int *i = (int *) malloc (100*sizeof(int));

I don't know much of C programming, but that is known to me as the
way you allocate an array of 100 integers on the heap in C.

Wrong; it's:

int *i = malloc (100*sizeof(int));

You should not cast the value returned by malloc; that can mask
errors.

Thanks for the correction. As I said, I have only little experience with
C, because I try to avoid it whenever possible... I strongly dislike C.

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
.



Relevant Pages

  • Re: WinCE Struct Help
    ... You can allocate *anything* with malloc() except a C++ object that needs to ... have its constructor called, so you can allocate your array with it, you can ... > Some of us just started programming while others are more advanced. ...
    (microsoft.public.windowsce.app.development)
  • Re: C or C++ for FOSS/linux?
    ... On 2006-12-29, Sebastian 'lunar' Wiesner wrote: ... I don't know much of C programming, but that is known to me as the way ... you allocate an array of 100 integers on the heap in C. ...
    (comp.os.linux.development.apps)
  • Re: When will this ng come to accept that Fortran needs to go "back to the future" ?
    ... Fortran programming - I never felt a real need for it - and I wrote ... with higher array limits). ... After all - my company paid to send me to a 5-day C programming class ... as an allocable array of one dimension, with intrinsics (allocate, ...
    (comp.lang.fortran)
  • Re: fished from a long thread
    ... No-one has freedom. ... We are all programmed from birth, by society and ... to behave in certain ways and we choose to live within our ... programming such as provided by Dianetics: ...
    (comp.lang.cobol)
  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... Of cause we have a freedom to choose safest of dangerouse programming ... But if we choose the safest language, ... Human freedom is a much different than programming freedom. ...
    (comp.lang.ada)