I'm new to C and i'm trying to store some strings inside a 2D array of chars.Here's what i have:
char strArray[100][100];
char input[100];
scanf("%s",&input);
strArray[i] = input; //this is where i get the incompatible types assignment error
As shown in the comment i get an incompatible types in assignment error.Do i need to use an array of char *strArray[100][100] ? Aren't strArray and input both of the same type (char [])? The one's 1D and the other is 2D obviously but i just didn't specify the 2nd dimension in the assignment since each string is stored in a new line. What am i doing wrong?
scanf("%s",&input);->scanf("%s",input);,strArray[i] = input;->strcpy(strArray[i], input);inputdecays to a pointer tocharwhile&inputis a pointer tochar[100]. So it is not the same, and%sexpects a pointer tochar.memcpy. You can not copy arrays with the=operator.