Assanges, you have to keep in mind that when you are working with matrices you need to pass the full address of the position to which you want to make an assignment. The declaration and use of matrix and vector are different.
char vet[2]; //Isso é um vetor de duas posições
char matriz[2][5]; //Isso é uma matriz com 2 linhas e 5 colunas
Therefore, conceptually we can represent the disposition of the elements in memory in the following way:
A fun Fact about the matrix that we normally don’t need to worry about in PC programming is that although there is this "theoretical" arrangement of the elements in matrix format, the elements are actually arranged in memory spaces sequentially, i.e., for the above example matrix[ 1 ][ 0 ] in memory comes right after matrix[ 0 ][ 4 ]
Another fact about matrices is that when you reference it in this way "matrix[ 1 ]" you are pointing to the value of the memory address.
You can test with the example below:
#include <stdio.h>
#include <string.h>
int main(void){
char v2[2][5];
printf("%d", v2[0]); //Imprimirá um número X
printf("\n%d\n", v2[1]); //Imprimirá um número X+5, pois a linha 0 tem 5 colunas
return 0;
}
But anyway, to assign a value to a position of the matrix you need to pass the position completely. Example:
char matriz[2][3];
matriz[1][2] = 'a';
The result would be:
I think the compiler disagrees about who’s on line 10...
– Jefferson Quesado
My previous comment was obsolete after editing =]
– Jefferson Quesado
that I had been doing a lot of editing on the code went unnoticed
– user45474