7
How a matrix of strings
?
I tried it in several ways and still did not succeed, I thought it would work but it did not work.
#include <stdio.h>
#include <stdlib.h>
int main(void){
char matriz[2][2];
char string1[] = "Minha string";
matriz[0][0] = string1;
printf("%s", matriz[0][0]);
return 0;
}
C and its peculiarities rs
– user45474
The problem is with the rule of decay of the types during assignment, sometimes gets confused. In matrix[0][0] = string1;, the type of string1 is char [] and decay to char * , so you need a variable that accommodates a char pointer, even if you never explicitly declare a pointer.
– aviana