Im a beginner level programmer in C and want to know how can I use malloc or calloc functions for dynamic memory allocation without typecasting...?
macrogeek 0 Newbie Poster
Recommended Answers
Jump to PostNo casting or typecasting is needed for malloc(). It returns a void pointer which the program will automatically change to the right type, for you. Very rarely, you'll need to do a cast of the pointer, manually.
You need to include stdlib.h for malloc to work.
If you …
Jump to Post>Well, casting is not the same thing as typecasting.
Erm, yes it is.>Typecasting just creates an "alias" (another name), your program
…
>can use, for a certain datatype (typically a struct name).
You're thinking of typedefing. Casting, typecasting, explicit conversion, and type coercion are pretty much the same thing.
Jump to Post>Both describe typedef as making a "synonym" or "another name", for a data type
Yes, that's how I describe them too. But one mustn't confuse "typedef" with "typecast". That's how I interpreted your initial statement, and why I corrected what I perceived to be the problem.
All 11 Replies
Adak 419 Nearly a Posting Virtuoso
prvnkmr449 -8 Junior Poster
macrogeek 0 Newbie Poster
Adak 419 Nearly a Posting Virtuoso
Narue 5,707 Bad Cop Team Colleague
Adak 419 Nearly a Posting Virtuoso
Narue 5,707 Bad Cop Team Colleague
Adak 419 Nearly a Posting Virtuoso
prvnkmr449 -8 Junior Poster
ronaldeddy 0 Newbie Poster
manojwali -4 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.