char array problem

hello

i have a program in C (Unix - SOlaris5.7), and i have the next question:

i have a lot of char variable, and i want store their values in a char array. The problem is what i don�t know how to put the char variable's value into the array, and i don`t know how to define the array

please help ... thanks

Your question isn't very specific, so here is a not very spefic answer:

char my_array[20][200]={0x0}; /* twenty character strings 200 long */
strcpy(my_array[0],somestring);
strcpy(my_array[1],another_char_array);
......
strcpy(my_array[19],yet_another_char_array);

jim mcnamara:

i did it, but i have the next error:

line 420: warning: improper pointer/integer combination: arg #2

this is the code:

pos=(ERR_SEX_BEN * 10) + err_caec[ERR_SEX_BEN][DETALLE];
strcpy(valor_detallechar[pos],regcaec.sexben); [/COLOR]

and regcaec.sexben was defined like this:
struct r1
{
char tipreg,sexben,coneme,perred,asipre;
} regcaec;

pleasse , help me
thanks

I think your problem is that you are trying to copy a single character. You have to do this as:
valor_detallechar[pos]=regcaec.sexben;

The thing is that valor_detallechar[pos] is used to calculate the position where the code will act (the pointer in your error), while the regcaec.sexben, being a character, is treated as ascii code (integer).
I mean, strcpy requires strings (pointers to the base of the strings, actually) as arguments. Your second argument is not "const char *src".

I haven't been terribly clear, but hope that this helps.

I will easy when you use a pointer character. This is the easier way to define character of array.

example.

char *name[10]

the above will store 10 names in string format i.e.,

name[1]='senthil'
name[2]='zzzzzzz'
and so on upto 10.

regards,
Senthil K