开发者

Initializing a static const char* array

开发者 https://www.devze.com 2023-01-18 10:48 出处:网络
here is my question I have this in my .h file static 开发者_Go百科const char *Title[]; How do I initialize the array in my .C file the array to lets say \"first\", \"second\", \"third\"static const

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

static 开发者_Go百科const char *Title[];

How do I initialize the array in my .C file the array to lets say "first", "second", "third"


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" };


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

0

精彩评论

暂无评论...
验证码 换一张
取 消