Use a two-dimensional pointer array of type char to create an array of strings - C String

C examples for String:String Array

Description

Use a two-dimensional pointer array of type char to create an array of strings

Demo Code

#include <stdio.h> 
int main()/*w  w  w .  jav  a  2s.c o  m*/
{  
   char *colors[3][10] = {'\0'}; 
  
   printf("\nEnter 3 colors seperated by spaces: "); 
  
   scanf("%s %s %s", colors[0], colors[1], colors[2]); 
  
   printf("\nYour entered: "); 
  
   printf("%s %s %s\n", colors[0], colors[1], colors[2]); 
}

Related Tutorials