0

I'm trying to set an array to a string from another array. This is in C programming.

gates[gatenum]=&seperation[a+1];

where both a and gatenum are both ints. And both arrays are declared as:

char seperation[3000][100];
char *gates[100][10];

So basically what I'm asking is how can I set gates[gatenum] to the string that is in seperation[a+1]

Thank you in advance

3
  • I still get the same compiling error when I get rid of the &. Yeah I just want to copy the string from seperation to gates. Commented Sep 25, 2013 at 1:24
  • Are the arrays really declared like that? One is char * and the other is just char? Commented Sep 25, 2013 at 1:35
  • gates is still char * and the other is just char Commented Sep 25, 2013 at 1:38

2 Answers 2

1

Drop the second dimension of gates.

char *gates[100];

Then you can assign gates[gatenum] = seperation[a+1];

Sign up to request clarification or add additional context in comments.

1 Comment

That worked thank you. I'd up vote you but I don't have enough reputation.
0

strncpy(gates,seperation,sizeof(gates));

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.