i'd like know how to read more than 1 string without using a structure and display them
reading more than 1 string in c
Collapse
X
-
A string in C is usually or always (?) held in an array characters of length n-1 to allow a space for the NULL character '\0' . You can get the number of elements using sizeof(); <sizeof() becomes the terminating argument in the for loop
So if you had say three arrays each containing a string of characters you could read them with two for loops.
The first loop would pick the array say char_string s1 then char_string s2 then char_string s3
The second loop would display the individual elements of each array in turn.
Does this fit with what you had in mind?Comment
-
declare the array of pointers, then allocate the memory for, when string is initialzed, let me know, do u got a picture of your question?Comment
Comment