목록Language (2)
J.BF Story
PHP 내장 함수인 array_filter을 통해 조건에 부합하는 배열 요소만 필터링할 수 있다. 공식 문서 PHP: array_filter - Manual Depending on the intended meanings of your "empty" array values, e.g., null and empty string, vs. an integer 0 or a boolean false, be mindful of the result of different filters. null, 'nullstring' => '', 'intzero' => 0, 'stringzero' => '0', 'false' => www.php.net 다음과 같은 방법으로 콜백함수와 모드를 통해 필터링할 수 있다. 명명 필터 함수 사..
size_t strlen(const char* str) string length header: 문자열 길이 반환 char*가 가리키는 주소에서 '\0' 문자 전까지의 문자 개수 ** '\0': 문자열에서 문자열 끝을 알려주는 문자 char* test = "Hello World!"; // Hello World!\0 회고 바이너리 파일에서 읽은 데이터를 strlen을 이용하여 1byte 씩 프린트하는 작업을 하고있었는데 원래 데이터와 길이가 다르게 반환되어 찾아보게 되었다. 다음과 같은 바이너리 데이터에서 strlen을 사용했을 경우 '\x00'(빨간 네모 박스)값을 문자열 끝이라고 인식해서 '\x00' 이전 문자의 개수가 반환되었다. stat 함수의 파일 크기(st_size)를 이용하여 해결하였다.