How would I make an array to store strings?

前端 未结 4 1656
暖寄归人
暖寄归人 2021-01-29 11:22

So I\'m trying to figure this out with a simple program:

#include 
#include 
#include 
 int main()
{
    char a[]=         


        
4条回答
  •  旧时难觅i
    2021-01-29 11:45

    To store entire string use string copy.

    char a[]="lalala"; 
    char c[]="nanana";
    char d[3][10];
    
    strcpy(d[0],a);
    strcpy(d[1],b);
    strcpy(d[2],c);
    
    printf("%s -- %s -- %s", d[0], d[1], d[2]);
    

提交回复
热议问题