Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h> int main() { char str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; } ?->(Show Answer!)
1. If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h> int main() { char str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.02 pm
Step 1: char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; The variable str is declared as an pointer to the array of 6 strings. Step 2: printf("%d, %d", sizeof(str), strlen(str[0])); sizeof(str) denotes 6 * 4 bytes = 24 bytes. Hence it prints '24' strlen(str[0])); becomes strlen(Frogs)). Hence it prints '5'; Hence the output of the program is 24, 5 Hint: If you run the above code in 16 bit platform (Turbo C under DOS) the output will be 12, 5. Because the pointer occupies only 2 bytes. If you run the above code in Linux (32 bit platform), the output will be 24, 5 (because the size of pointer is 4 bytes).