Initializing a static const char* array

前端 未结 2 1569
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 17:41

here is my question I have this in my .h file

static const char *Title[];

How do I initialize the array in my .C file the array to lets say \"f

相关标签:
2条回答
  • 2021-02-15 18:04

    If it's C++ you could wrap this array about a class and create a static instance of it.

    0 讨论(0)
  • 2021-02-15 18:11

    static const char* Title[] = { "first", "second", "third" };

    Check out this little blurb on initialization. Why do you want to do it in separate files? You'll have to do externs.

    // in .h
    extern const char* Title[];
    
    // in .c
    const char* Title[] = { "first", "second" };
    
    0 讨论(0)
提交回复
热议问题