본문 바로가기

전체 글

(72)
main function arguments [leechul@~/C_Study]leechul cat 013-main-arg.c int main(int argc, char *argv[]) { int i; printf("argc = %d\n",argc); for(i = 0; i < argc; i++) { printf("argv[%d] = %s\n", i, argv[i]); } return 0; } [leechul@~/C_Study]leechul ./013-main-arg.o hello world "hello world" test argc = 5 argv[0] = ./013-main-arg.o argv[1] = hello argv[2] = world argv[3] = hello world argv[4] = test
structure [leechul@~/C_Study]leechul cat 012-structure.c #include int main(int argc, char argv[]) { struct { int a; float b; int c; } myst; myst.a = 4; myst.b = 3.37; myst.c = 8; printf("a = %d, b=%f, c = %d\n", myst.a, myst.b, myst.c); return 0;}[leechul@~/C_Study]leechul gcc 012-structure.c -o 012-structure.o[leechul@~/C_Study]leechul ./012-structure.o a = 4, b=3.370000, c = 8
function pointer [leechul@~/C_Study]leechul cat 011-function-pointer.c #include int add_numbers(int a, int b){ int sum; sum = a + b; return sum;} int main(int argc, char argv[]) { int result; //function pointer int (*myfunc_ptr)(int, int); myfunc_ptr = &add_numbers; result = myfunc_ptr(3,5); printf("result = %d\n", result); return 0;}[leechul@~/C_Study]leechul gcc 011-function-pointer.c -o 011-function-pointer.o..
array [leechul@~/C_Study]leechul cat 010-array.c #include int main(int argc, char argv[]){ int a[4]; int b[4] = { 2,6,3,8 }; a[0] = 3; a[1] = 2; a[2] = 7; a[3] = 9; printf("a values are: %d, %d, %d, %d, \n", a[0], a[1], a[2], a[3]); printf("b values are: %d, %d, %d, %d, \n", b[0], b[1], b[2], b[3]); return 0;}[leechul@~/C_Study]leechul gcc 010-array.c -o 010-array.o[leechul@~/C_Study]leechul ./010-arr..
for-loop [leechul@~/C_Study]leechul cat 009-for-loop.c #include int main(int argc, char argv[]){ int i; for(i=0;i
pointer [leechul@~/C_Study]leechul cat 008-pointer.c #include int main(int argc, char argv[]) { int n; int *p; n = 25; p = &n; printf("n = %d\n", n); //%d intger printf("p = %x\n", p); //%x Unsigned hexadecimal integer ##Example 7fa printf("*p = %d\n", *p); return 0; } [leechul@~/C_Study]leechul gcc 008-pointer.c -o 008-pointer.o [leechul@~/C_Study]leechul ./008-pointer.o n = 25 p = bfb1491c *p = 25
function [leechul@~/C_Study]leechul vi 003-functions.c #include int sum(int a, int b); int main(int argc, char *argv[]) { int result; result = sum(5,10); printf ("result = %d\n",result); } int sum(int a, int b) { int result; result = a + b; return result; } [leechul@~/C_Study]leechul gcc 003-functions.c -o 003-functions.o [leechul@~/C_Study]leechul ./003-functions.o result = 15
bitwise operator Bit valueResults of in expr1 in expr2 expr1 & expr2expr1 ^ expr2expr1 | expr200000100110101111101