This probably has to do with C pointers cause it's an array problem.
Is it possible to assign an index of one array to another:
int main()
{
char a[10];
char b[3] = {'a', 'b', 'c'};
int num = 1;
a[1 + num] = b[0];
int i = 0;
for(i; i < 3; i++)
printf("%s", a[i]);
return 0;
}
I think the output should be what a would be. which i think would be [(null), (null), a]
EDIT
say I add an int array c to the code above:
int c[3] = {1, 2, 3};
I am having trouble with storing values in the array a when I try to do something like this:
a[1 + c[0]] = b[0];
this ended up working as well...
it turns out this was not my issue thanks for the help though
printf("%s", a[i]);shouldn't that beprintf("%c", a[i]);?%cnot%s. Also, you should initialize arrayaotherwise you will be printing two uninitialized characters.