How do I create an array of strings in C?

前端 未结 14 2511
野的像风
野的像风 2020-11-22 14:43

I am trying to create an array of strings in C. If I use this code:

char (*a[2])[14];
a[0]=\"blah\";
a[1]=\"hmm\";

gcc gives me \"warning:

14条回答
  •  隐瞒了意图╮
    2020-11-22 15:14

    A good way is to define a string your self.

    #include 
    typedef char string[]
    int main() {
        string test = "string";
        return 0;
    }
    

    It's really that simple.

提交回复
热议问题