`sizeof` Function Is not Working as Expected With AVR Microcontroller
Don't use the sizeof operator. char[10], char[40], char* are all slightly different data types and return different sizes.
Use strlen to find the length of a string if your micro controller library provides it. If it doesn't, write one yourself by counting till you find the string terminating character, usually '\0'.
See a sample code below.
int i;

// store length in a variable.
// dont call strlen ever loop iteration.
int len = strlen(string);

for(i=0; i&lt; len; i++){
// do something
}