String array in C

#include <stdio.h>
int main(void){
char str[4][20]={"Alex","Roan","Allen","Roman"};
int i;
for(i=0;i<=3;i++){
   printf("%s \n",str[i]);
}

return 0;
}
Output is here
Alex
Roan
Allen
Roman

Reading names and storing in string arrays to display

You can read full name ( with space ) and then display the same.
#include <stdio.h>
#include <string.h>
int main(void){
char str[4][20];
int i;
for(i=0;i<=3;i++){
   printf("Enter one name \n");
   gets(str[i]);
}
for(i=0;i<=3;i++){
   printf("%s\n",str[i]);
}

return 0;
}
Basics of array
Your Rating




Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer