Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

Is there anyway in C we could create an array dynamically??? Like when the user gives the input as 5, then we need to have an array of length 5 ...???? any suggestion mates???

OpenStudy (anonymous):

malloc

OpenStudy (anonymous):

if we could Use malloc, then we would loose the contiguous memory allocation of the array????? wont we?

OpenStudy (anonymous):

wrong, malloc gives you a contiguous block of memory of the specified size

OpenStudy (anonymous):

can U pls help with the coding part???

OpenStudy (anonymous):

Example: Allocate a character buffer of 512 characters. char* Buffer = malloc ( 512 );

OpenStudy (anonymous):

Sorry forgot the cast. char* Buffer = (char*) malloc ( 512 );

OpenStudy (anonymous):

cool :) :) :) got it :) thanks a lot :)

OpenStudy (anonymous):

malloc

OpenStudy (anonymous):

Also don't forget to free() it after using malloc() ;)

OpenStudy (anonymous):

sure sure :) :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Breathless: Spooky witch but cute
3 hours ago 3 Replies 0 Medals
Arriyanalol: help
3 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 3 Medals
Jaded012023: Please tell me what you all think of this song
6 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
6 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!