hello,
how can i print an array of strings? how do i make this array
thank you.
hello,
how can i print an array of strings? how do i make this array
thank you.
An array of strings can be done like so
Code:#include <stdio.h> int main(void) { char array[][7] = { {"First"}, {"Second"}, {"Third"}, {"Fourth"} }; int x; for(x=0; x<4; x++) printf("\n%s", array[x]); return 0; }
All spelling mistakes, syntatical errors and stupid comments are intentional.
the other way of doing what Mr. C_Coder has provided is the following:
---------------------------------------------------------------------------
#include <stdio.h>
int main(void)
{
char *array[] = { "First",
"Second",
"Third",
"Fourth"};
int x;
for(x=0; x<4; x++)
printf("\n%s", array[x]);
return 0;
}
the latter solution is more space-efficient.