본문 바로가기

함수

strcmp 함수의 모호한 return value strcmp 함수는 스트링간 포함여부를 찾는데는 사용하기 어렵다. strstr 이나 strchar 를 사용해야 한다.두 string 이 완전히 동일한지만 판단이 용이하다. #include //#include #include #include #include #include #include #include // O_WRONLY#include // strlen() #define BUFF_SIZE 1024 int main(){ const char* standard = "12345"; const char* standard2 = "0123456"; const char* wrong = "a12"; const char* part = "234"; int rst=0; rst = strcmp(standard, standar.. 더보기
헷갈리는 c string 함수들 정리중... strstr은 문자열 중에서 특정 문구를 찾아 그 위치를 반환해 주는 함수특히, 포함된 문자열을 찾는데 유용하다. (strcmp 를 사용하면 안된다 !!) /*strstr */char * strstr(const char * str1, const char * str2); 참조 : http://tapito.tistory.com/313 1. strcat - strcat (string concatenation)은 문자열 2개를 이어 붙이는 역할을 해주는 함수이다. 예컨대, "Love"와 "You"를 합치면 LoveYou가 될 것이다. 이처럼 두개의 문자열을 합쳐주는 함수가 strcat 이다. 이 함수의 사용방법과 내부적인 결과를 자세히 살펴보자. 먼저 함수의 모양을 알아보자. 함수.. 더보기
symbol table 로 code area 에서 함수 위치 찾기 readelf -s library.so 를 치면 symbol table 이 나온다. 9315: 000c3230 28 FUNC LOCAL DEFAULT 11 __GI_delete_module 9316: 00093188 540 FUNC LOCAL DEFAULT 11 __pathconf 9317: 0006ca08 952 FUNC LOCAL DEFAULT 11 __malloc 9318: 00059b88 236 FUNC LOCAL DEFAULT 11 _IO_padn_internal 9319: 000b4614 24 FUNC LOCAL DEFAULT 11 __read_nocancel # cat /proc/1456/maps 을 해서 나온 code 영역에서 40242000-4035b000 r-xp 00000000 8b:.. 더보기