This question already has an answer here:
I have a problem when acquiring the size of an array of type char, I pass an array of type char to a function and in the function I want to get the size, but I can't get the correct one.
void dato(char data[]);
int main (){
char datos[6];
dato(datos);
}
void dato(char data[]){
int Long_data = sizeof(data) / sizeof(data[0]);
printf("long data = %i\n", Long_data);
}
I expect the output of long_data to be 6, but the actual output is 4.
Aucun commentaire:
Enregistrer un commentaire