CS 지식

Makefile (메이크파일) 이란 무엇일까? C언어로 소스코드를 작성하고 나서, 실행하기 위해 우리는 컴파일이라는 과정을 거친다. 컴파일러를 호출하여 대상 소스파일을 넘겨주고, 실행파일을 생성한다. gcc -c main.c// main.o 라는 object file (목적파일) 생성 gcc main.c// 자동으로 a.out 이라는 실행파일이 생성됨 (기본값) gcc main.c -o b.out// b.out 이라는 이름의 실행파일 생성 그런데, 이렇게 일일이 파일이름을 나열하여 컴파일하는 과정은 소스파일이 적을 때는 가능하겠지만, 규모가 큰 프로젝트 같은 경우에는 굉장히 비효율적인 작업이 된다. SRCS=ft_itoa.c ft_split.c ft_strtrim.c ft_calloc.c ft_strdu..
https://blog.encrypted.gg/923 [실전 알고리즘] 0x02강 - 기초 코드 작성 요령 II 안녕하세요, 바킹독입니다. 이전 단원에서 오지고 지리게 고통받으셨을텐데 이번에는 훨씬 쉬우니까 걱정을 덜어내시고 마음 편하게 보시면 됩니다. 저 아직 0x18살이니까 급식체 써도 되는거 blog.encrypted.gg 기초 코드 작성 요령 II 1. cin / cout 사용하기 2. vector 사용하기 3. 함수로 vector를 넘길 때 단순 값 비교, 참조 등만 할 경우 & 붙여서 주소 값 넘겨주기 -> 일반적으로 변수처럼 값을 넘기게 되면 vector의 모든 인덱스가 복사되어서 넘어가기에 O(N) 시간복잡도 발생 4. endl 쓰지 않기! 무조건 개행문자로 대체하기
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: intopen(const char *path, int oflag, ...); 함수 설명: The file name specified by path is opened for reading and or writing, as specified by the argument oflag; the file descriptor is returned to the calling process. path 파라미터에 명시된 파일을 읽기 또는 쓰기를 위해 여는 함수. 정확히 어떤 동작을 할 건지는 oflag 파라미터로 설정하는데, 리턴 값으로 파일 디스크립터 (file descriptor, fd) 값을 넘겨준다. The flags specifie..
널 포인터 (Null Pointer)는 아무것도 가리키지 않는 포인터이다. 단순히 선언만 되고 초기화되지 않은 포인터와는 다르게 생각해야 한다. 널 포인터를 사용하는 이유는, 단순히 초기화되지 않은 포인터와 다르게 메모리 상의 어떠한 값을 가리키지 않기 때문이다. 초기화되지 않은 포인터는 쓰레기값이 들어갈 수 있기 때문에 어떠한 값을 가리킬 수 있다. #include int main() { int *numPtr = NULL;// NULL은 널 포인터 상수 (정수값 0)으로 정의된다. printf("%p\n", numPtr);// 0x0 "아무것도 가리키지 않음" 을 의미하는 주소값 0이 나온다. return 0; } 또한, 널 포인터는 널 문자 ('\0') 과는 다른 의미를 가진다. 널 포인터를 역참조하..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: char*strdup (const char *s1); 함수 설명: The strdup() function allocates sufficient memory for a copy of the string s1, does the copy, and returns a pointer to it. The pointer may subsequently be used as an argument to the function free(3). strdup()함수는 문자열 s1을 복사한 다음에 복사본에 충분한 메모리를 할당을 하고, 그 복사본의 포인터를 반환한다. 해당 포인터를 가지고 free()함수를 쓸 수 있다. If insufficient m..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: ssize_t write(int fildes, const void *buf, size_t nbyte); /* fildes는 쓰고자 하는 파일 디스크립터 (file descriptor), buf는 쓰고자 하는 문자의 주소, nbyte는 해당 위치에서 몇 바이트를 출력할 지 */ 함수 설명: write() attempts to write nbyte of data to the object referenced by the descriptor fildes from the buffer pointed to by buf. 첫 번째 인자인 fd값은 주로 0, 1, 2가 사용되는데 각각 표준 입력, 표준 출력, 표준 에러를 의미한다. 두 번..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: char * strstr(const char *haystack, const char *needle); /* haystack은 큰 문자열, needle은 큰 문자열 haystack에서 찾을 대상 문자열이다 */ /* 건초더미와 바늘이라는 작명센스가 돋보임 */ 함수 설명: The strstr() function locates the first occurrence of the null-terminated string needle in the null-terminated string haystack. strstr() 함수는 null-terminating 문자열 needle을 null-terminating 문자열 haystack에..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: char * strcat(char *restrict s1, const char *restrict s2); char * strncat(char *restrict s1, const char *restrict s2, size_t n); 함수 설명: ** YOU SHOULD ALMOST CERTAINLY USE strlcat() INSTEAD. ** 그냥 strlcat() 쓰자 The strcat() and strncat() functions append a copy of the null-terminated string s2 to the end of the null-terminated string s1, then add a ter..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: int strcmp(const char *s1, const char *s2); int strncmp(const char *s1, const char *s2, size_t n); /* s1, s2는 비교할 문자열, n은 앞에서 부터 몇 번째 까지 비교할 건지 */ 함수 설명: The strcmp() and strncmp() functions lexicographically compare the null-terminated strings s1 and s2. strcmp()와 strncmp()함수는 사전순으로 문자열 s1, s2를 비교한다. The strncmp() function compares not more than n c..
man page에 검색해 보자. 소속 헤더파일: #include 함수 프로토타입: size_t strlcpy(char *restrict dst, const char *restrict src, size_t dstsize); /* dst는 복사한 것을 붙여넣을 문자열, src는 복사되는 문자열, dstsize는 붙여넣고 난 후의 dst 길이 */ size_t strlcat(char * restrict dst, const char *restrict src, size_t dstsize); /* dst는 원래 문자열, src는 추가되는 문자열, dstsize는 추가하고 난 후의 dst 길이 */ 함수 설명: The strlcpy() and strlcat() function copy and concatenate s..
kmicety1
'CS 지식' 카테고리의 글 목록