/* sample.c */ #include<stdio.h> int main(int argc, int *argv) { int i; for(i=1; i<argc; i++) printf("%s\n", argv[i]); return 0; }
In a loop, there is no recursive call involved that saves a lot of time and space too.
#include<stdio.h> void fact(int*); int main() { int i=5; fact(&i); printf("%d\n", i); return 0; } void fact(int *j) { static int s=1; if(*j!=0) { s = s**j; *j = *j-1; fact(j); /* Add a statement here */ } }
#include<stdio.h> int main() { unsigned char i = 0x80; printf("%d\n", i<<1); return 0; }
#include<stdio.h> int main() { int fun(); int i; i = fun(); printf("%d\n", i); return 0; } int fun() { _AX = 1990; }
But it may not work as expected in GCC compiler (Linux).
#include<stdio.h> int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *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("%d %s", argc, argv[1]); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.