I'm trying to learn about malloc in C. I've done some java programming but want to learn the nuts and bolts of coding.
Let me explain what I know about this and hopefully someone can fill in the gaps.
In the line:
str = (char *) malloc(15);
I'm aware that what we're doing here is allocating memory to this string. 15 units of memory, I assume that the 15 units are 15 bytes, as 1 char takes up one byte (Is that right?)
Whats confusing me is the (char *) what does this mean? I know that * is the pointer and de-reference operator, but I'm lost as to what it means in this context.
From my limited experience in programming, my first guess is that (char *) is an explicit cast.. but I'm not sure exactly.
I apologise if this has been asked before, but I have searched, and I have also googled (char *) and variations like (int *) which I've seen in other examples, but can't seem to get an explanation.
Any help most appreciated.