How to declare this ?

Recommended Answers

All 6 Replies

It's just a multi-dimensional array of char...

//an array of char
char charArray[80];

//an array of char*
char* charpArray[80];
//OR
//an array of arrays of char
char mdCharArray[25][80]; //25 80-char arrays

It's exactly like the main() parameter char *argv[] (which is another way to do it)

Or did you mean something else?

To tell you the truth i need something like:

char* months[] = {"january","february","march","april"};

But i get thi warnings:warning: deprecated conversion from string constant to ‘char*’

Hmm....I don't get that warning.

Are you using/compiling as C++ 0x? I wonder if that's something that comes from the new draft...

I use g++ with eclipse in linux

> deprecated conversion from string constant to ‘char*’

The string literals are constants, so using const is in order, like so

const char * months[] = {"january","february","march","april"};

pointer to array of character strings... If by character string you mean const char*, and if you MEAN you want to declare a pointer to array of pointers to const char(which I doubt), then it will be like this

typedef const char * str_type;
typedef str_type arr_type[100];
typedef arr_type* my_desired_type;

my_desired_type var; //var is a pointer to array of pointers to const char

Or, the same without the typedefs will be

const char * (*var)[100];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.