#include<stdio.h> int main() { const int i=0; printf("%d\n", i++); return 0; }
Step 1: const int i=0; The constant variable 'i' is declared as an integer and initialized with value of '0'(zero).
Step 2: printf("%d\n", i++); Here the variable 'i' is increemented by 1(one). This will create an error "Cannot modify a const object".
Because, we cannot modify a const variable.
#include<stdio.h> int X=40; int main() { int X=20; printf("%d\n", X); return 0; }
/* myprog.c */ #include<stdio.h> #include<stdlib.h> int main(int argc, char **argv) { int i; for(i=1; i<=3; i++) printf("%u\n", &argv[i]); return 0; }If the first value printed by the above program is 65517, what will be the rest of output?
#include<stdio.h> #include<stdlib.h> int main() { int *p; p = (int *)malloc(20); /* Assume p has address of 1314 */ free(p); printf("%u", p); return 0; }
#include<stdio.h> int main() { int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8}; int *p, *q; p = &arr[1][1][1]; q = (int*) arr; printf("%d, %d\n", *p, *q); return 0; }
#include<stdio.h> int main() { char near *near *ptr1; char near *far *ptr2; char near *huge *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; }
/* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%s\n", argv[0]); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.