# Thread: Struct Char Array Problems

1. ## Struct Char Array Problems

I am trying to put a char array into a struct but everything I have tried has not worked.

Code:
```typedef struct{
int Grid_X;
int Grid_Y;
char Room_Name[30];
int North;
int South;
int East;
int West;
int Warp;
int Warp_X;
int Warp_Y;
int Chest;
}Room;

Room RG; //in main

char Name[30] = (*RG).Room_Name; //line 71
//In another function

void set_room_start(Room *RG){
(*RG).Grid_X = 0;
(*RG).Grid_Y = 0;
(*RG).Room_Name[30] = "Start Room"; //line 14
(*RG).North = 1;
(*RG).South = 1;
(*RG).East = 1;
(*RG).West = 1;
(*RG).Warp = 1;
(*RG).Warp_X = 5;
(*RG).Warp_Y = 0;
(*RG).Chest = 1;
}```

That gives me warnings:
"14 E:\Code\Source Code\Game Commands.c [Warning] assignment makes integer from pointer without a cast"

"71 E:\Code\Source Code\Game Commands.c array initialized from non-constant array expression"

Could some one point out the mistake I am making in my struct code? Thanx in advance
RMDan

Edit:
For those who may be picky, Yes I did pas the address of RG to my functions.

2. arrays don't work that way

3. Looks like maybe you need to use the strcpy function.

4. Code:
`(*RG).Grid_X = 0;`
It is quite a bit easier to just write:
Code:
`RG->Grid_X = 0;`
And as others have stated, read up on how to use strcpy().

5. #1 tip about the number one:

Get one of something to actually work before you code ten of them the same, completely wrongly.

6. I forgot about strcpy. That makes a huge difference.

hk_mp5kpdw:
Thanks that got rid of the errors

bithub:
Thanks for the tip. Going to change that in my engine later.

MK27:
My Struct is perfectly fine except for one line. I got the ints to work for me then I attempted to put a char in the Struct. So basically I did what you said so don't post criticism.

RMDan