I need to make an array of strings for a program in one of my CS classes. We are to just assume that the length of all the strings is no more than 50 (this accounts for the null character).
I need use malloc() or calloc() to allocate the proper amount of memory for the array, but I am new to C and I don’t really know how to use those functions.
The real question I guess is how much memory to I need do allocate for an array of x strings of 50 characters.
\0is called the termination character for strings.What you need is array of char pointers.
Now each index holds pointer to an array that is allocated by
malloc(50);Example: