malloc

Dynamically Allocate Memory For An Array Of Strings | C Programming Example

0:00
↔️ ↕️

Timecodes:

on a recent video a viewer asked if we

could make a video on how to dynamically

allocate memory for an array of strings

in c

so that's what we're going to do in this

video

we're going to dynamically allocate

memory for an array of strings so if we

wanted to dynamically allocate space for

a single string on the heap it would

look something like this

we'd say car star string

is equal to

and we would call malloc

and we would say size of car

times length

where here we're pretending that length

is the length of the character array

that we want to create to store the

string that we're going to store into it

and then size of car


Related queries:


how to malloc a 2d char array in c
char array example