0
Hello, I’m trying to return a vector that receives the content of a matrix in a function, but it’s not working, I appreciate if someone can help me, I’m in doubt
Function call on main:
char vetor[tamMsg*9];
retornar_vetor(&mensagem, &vetor);
The function:
char* retornar_vetor(char **mensagem, char **vet) {
int i, j;
char cpy[2];
int tamanhoMsg = strlen(*mensagem);
char str[tamanhoMsg][9];
for(i=0; i<tamanhoMsg; i++){
str[i][0] = '\0';
for(j=0; j<8; j++){
sprintf(cpy,"%d", (*mensagem)[i]%2);
strcat(str[i], cpy);
vetor[j] = str[i]
(*mensagem)[i]/=2;
}
str[i][j] = '\0';
printf("%s", str[i]);
}
return vet;
printf("\n");
}
Note: The focus of the question is to be able to put the values of the matrix str
in the vector and return to the vector in main, so the pointer pointer, I’m not able to understand how to do
I don’t understand the doubt. Are you having any problems? As the rest, the problem may be how you are consuming. Anyway I’m pretty sure that’s been answered before.
– Maniero