본문 바로가기

C Programing

(15)
linux C언어 curl 사용하여 httpget요청보내기. curl 설치. 최신버전 curl 다운로드 https://curl.haxx.se/download.html [root@localhost ~]# wget https://curl.haxx.se/download/curl-7.49.1.tar.gz^C [root@localhost ~]# tar zxvf curl-7.49.1.tar.gz [root@localhost ~]# cd curl-7.49.1 [root@localhost curl-7.49.1]# ./configure [root@localhost curl-7.49.1]# make [root@localhost curl-7.49.1]# ./make install curl.h 사용하여 GET 요청 보내고 응답내용 출력하기 #include #include #includ..
openssl lib 사용시 -lssl -lcrypto 로 링크 걸때 에러 발생시 해결방법. -lssl -lcrypto 로 링크 걸때 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': dso_dlfcn.c:(.text+0x2d): undefined reference to `dlopen' dso_dlfcn.c:(.text+0x43): undefined reference to `dlsym' dso_dlfcn.c:(.text+0x4d): undefined reference to `dlclose' /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr': dso_dlfcn.c:(.text+0x8f): undefined reference..
BITWISE OPERAT ORS Operator Description& Bitwise AND operator| Bitwise OR operator^ Bitwise Exclusive OR (XOR) operator~ Bitwise NOT operator, also called the 1’s complement operator>> Bitwise shift right operator>= 4; printf("orignial = %X size= %d \n", original,sizeof(original)); result =4; printf("orignial = %X size= %d \n", original,sizeof(original)); result
if(0) and if(!0) [leechul@~/C_Study]leechul ./iftestwhen if(0)print elsewhen if(!0) print ifa=b [leechul@~/C_Study]leechul cat iftest.c #include #include int main(int argc, char *argv[]) { char a[24] = "test"; char b[24] = "test"; if (0) { printf("when if(0)print if\n"); } else { printf("when if(0)print else\n"); } if (!0) { printf("when if(!0) print if\n"); } else { printf("when if(!) print else\n"); } if (!str..
string functions and operations man string.h 명령어를 사용하여 함수에 대한 내용을 검색. [leechul@~/C_Study]leechul vi 016-string-functions-and-operations.c#include #include int main(int argc, char *argv[]){ char str[24]; char str2[24]; int i; int n; /* Example 1 */ sprintf(str, "Hello World!"); printf("%s\n",str); /* Example 2 */ i = 4; sprintf(str, "Value of i = %d", i); printf("%s\n",str); /* Example 3 */ n = strlen(str); printf("length of st..
multiple-source-files 1. [leechul@leechul 015-multiple-source-files]$ lsaddnumbers.c mian.c[leechul@leechul 015-multiple-source-files]$ gcc -c mian.c [leechul@leechul 015-multiple-source-files]$ gcc -c addnumbers.c [leechul@leechul 015-multiple-source-files]$ lsaddnumbers.c addnumbers.o mian.c mian.o[leechul@leechul 015-multiple-source-files]$ gcc -o main mian.o addnumbers.o[leechul@leechul 015-multiple-source-files]..
typedef [leechul@~/C_Study]leechul cat 014-typedef.c#include typedef int INT32;typedef char MYSTR; typedef struct mystruct_t { int a; int b;} MYSTRX; int main(int argc, char *argv[]) { INT32 i; MYSTR mystr[20] = "Hello World"; MYSTRX gold; MYSTRX silver; MYSTRX bronze; gold.a = 2; gold.b = 4; printf(" i = %d\n", i); printf("mystr = %s\n", mystr); printf("gold.a = %d\n", gold.a); printf("gold.b = %d\n", ..
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