Hello I've been having trouble with a really simple concept, and I'm new to C, and other resources are confusing me.
I have declared an array, and want to set each element but get a: Warning: assignment makes integer from pointer without cast.
This is what I to did:
Code:
int main() {
char myArray[30];
myArray[0]="h";
myArray[1]=" ";
myArray[2]="i";
myArray[3]="\0";
return 0;
}
I know its illegal to assign in this way:
Code:
char myArray[30];
myArray="h i";
but I thought my first method should have worked. (I am not allowed to declare and initialize in the same step, I'm trying to set an array after it was declared). If anyone can tell me what mistake I'm making here, I would really appreciate it!