初始化一个静态const char *数组 [英] Initializing a static const char* array

查看:564
本文介绍了初始化一个静态const char *数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题我有我的.h文件

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

static const char *Title[];

如何初始化我的.C文件中的数组数组,让我们说first第二个,第三个

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

初始化。为什么要在单独的文件中执行它?你必须做externs。

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

这篇关于初始化一个静态const char *数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆