Store string into array in c

后端 未结 6 1343
孤城傲影
孤城傲影 2021-02-14 21:28

As i know, i can create an array with item inside such as:

char *test1[3]= {\"arrtest\",\"ao\", \"123\"};

but how can i store my input into arr

6条回答
  •  逝去的感伤
    2021-02-14 21:50

    This code inspired me on how to get my user input strings into an array. I'm new to C and to this board, my apologies if I'm not following some rules on how to post a comment. I'm trying to figure things out.

    #include 
    
    int main()
    
    {
    
    char strings[3][256];
    
    scanf("%s %s %s", strings[0], strings[1], strings[2]);
    
    printf("%s\n%s\n%s\n", strings[0], strings[1], strings[2]);
    
    }
    

提交回复
热议问题