8

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 "first", "second", "third"

2
  • 1
    Are you sure you really want this in a header file? Commented Sep 28, 2010 at 16:16
  • Well if it's in a class it would make sense wouldn't it? Commented Sep 29, 2010 at 17:45

2 Answers 2

20

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" };
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.