#include<stdio.h> int main() { char str[25] = "CuriousTab"; printf("%s\n", &str+2); return 0; }
Step 2: printf("%s\n", &str+2);
=> In the printf statement %s is string format specifier tells the compiler to print the string in the memory of &str+2
=> &str is a location of string "CuriousTab". Therefore &str+2 is another memory location.
Hence it prints the Garbage value.
#include<stdio.h> int main() { printf("%%%%\n"); return 0; }
#include<stdio.h> int main() { float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n"); return 0; }
#include<stdio.h>
int main()
{
float a=0.7;
printf("%.10f %.10f\n",0.7, a);
return 0;
}
Output:
0.7000000000 0.6999999881
/* sample.c */ #include<stdio.h> int main(int sizeofargv, char *argv[]) { while(sizeofargv) printf("%s", argv[--sizeofargv]); return 0; }
/* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%c", *++argv[2] ); return 0; }
#include<stdio.h> int main() { const int k=7; int *const q=&k; printf("%d", *q); return 0; }
#include<stdio.h>
union Point
{
unsigned int x:4;
unsigned int y:4;
int res;
};
int main()
{
union Point pt;
pt.x = 2;
pt.y = 3;
pt.res = pt.y;
printf("\n The value of res = %d" , pt.res);
return 0;
}
// Output: The value of res = 3
/* myprog.c */ #include<stdio.h> int main(int argc, char **argv) { int i; for(i=0; i<argc; i++) printf("%s\n", argv[i]); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.