본문 바로가기

C 언어138

[c] printf [c] printf 1.소스 #include int test1() { printf("hello world!! \n" ); printf("\n"); } int test2() { int i = 20; printf("int i = %d , %%d = %d, %%o = %o, %%x = %x\n", i, i, i, i ); printf("int i = %d , %%4d = [%4d]\n",i , i ); printf("\n"); } int test3() { unsigned long int i = 100; printf("unsigned long int i = %lu , %%4lu = [%4lu] \n", i , i ); printf("\n"); } int test4() { short int i = 100; pri.. 2016. 8. 3.
PHP_STRLCPY PHP_STRLCPY(dst, src, size, src_size) - 부제 : php7.0.6 소스 쪼개서 사용하기 1.소스(php.h) // // PHP_STRLCPY // write by jang, kyoung chip // #include #include /* * This is a fast version of strlcpy which should be used, if you * know the size of the destination buffer and if you know * the length of the source string. * * size is the allocated number of bytes of dst * src_size is the number of bytes excludi.. 2016. 7. 27.
매크로 사용하기(php소스 쪼개서 사용하기) 매크로 사용하기 부제 : php소스 쪼개서 사용하기(php7.0.8-src/sapi/cgi/cgi_main.c) 발췌 소스 if (!env_document_root && PG(doc_root)) { env_document_root = CGI_PUTENV("DOCUMENT_ROOT", PG(doc_root)); /* fix docroot */ TRANSLATE_SLASHES(env_document_root); } 1.소스 #include #include #define TRANSLATE_SLASHES(path) \ { \ char *tmp = path; \ while (*tmp) { \ if (*tmp == '\\') *tmp = '/'; \ tmp++; \ } \ } int main( int argc , .. 2016. 7. 21.
strdup char *strdup(const char *s) The strdup() function returns a pointer to a new string which is a duplicate of the string s 1.소스 #include #include #include int main( int argc , char ** argv ) { char *p; p = strdup("black falcon"); puts(p); free(p); return 0; } 결과 hacker@ubuntu:~/c$ gcc -o strdup1 strdup1.c hacker@ubuntu:~/c$ ./strdup1 black falcon hacker@ubuntu:~/c$ 2016. 7. 20.