What's wrong with "char *p = malloc(10);" ?

Answer Posted / guest

malloc returns a void pointer. It needs to be cast to char*
before allocating it to char* variable.
char *p = (char *)malloc(10); should do fine.

Is This Answer Correct ?    26 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are types of structure?

608


What is the difference between declaring a variable and defining a variable?

726


Explain setjmp()?

661


What are the disadvantages of external storage class?

593


using for loop sum 2 number of any 4 digit number in c language

1738






What is difference between stdio h and conio h?

890


differentiate built-in functions and user – defined functions.

634


Explain how do you determine the length of a string value that was stored in a variable?

673


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2658


What is the right type to use for boolean values in c?

589


Explain the properties of union.

615


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

693


What is the time and space complexities of merge sort and when is it preferred over quick sort?

678


What’s the special use of UNIONS?

663


I need previous papers of CSC.......plz help out by posting them.......

1818