본문 바로가기

C언어 in 42Seoul (라피신)

(11)
c07 00 src 크기 만큼의 포인터형 char배열을 만든 뒤 복사를 해줍니다. 문자열 배열이니 마지막에 널도 넣어주고 문자열배열 주소를 반환 #include #include #include #include char*ft_strdup(char *src) { inti; intj; char*dest; j = 0; i = 0; while (src[i]) i++; dest = (char *)malloc(sizeof(char) * (i + 1)); if (!dest) return (NULL); while (src[j]) { dest[j] = src[j]; j++; } dest[j] = '\0'; return (dest); } int main() { char as[10]="gege"; printf("%s\n",strdu..
시험정리 github.com/alanbarrett2/42-Final-Exam/blob/master/1-0-repeat_alpha/2019.c alanbarrett2/42-Final-Exam git hub 42 exam final. This has 42 exam questions. Alan Barrett's study guide and answers great for studying for the final! #42 #exam - alanbarrett2/42-Final-Exam github.com github.com/alanbarrett2/42-Final-Exam/blob/master/1-0-repeat_alpha/2019.c alanbarrett2/42-Final-Exam git hub 42 exam final...
c05 ex00 #include #include intft_iterative_factorial(int nb) { if (nb 문제 잘읽자 반복함수 작성하래서 아래로 바꿈 다음 문제에 재귀로 하라고 나옴. /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_ite..
exam01대비 only_a.c #include intmain(void) { write(1, "a", 1); return (0); } search_and_replace.c #include voidft_putchar(char c) { write(1, &c, 1); } voidft_replace(char *d, char a, char b) { int i; i = 0; while (d[i] != '\0') { if (d[i] == a) ft_putchar(b); else ft_putchar(d[i]); i++; } } intmain(int argc, char **argv) { if (argc == 4) { if (!(argv[3][1] != '\0' || argv[2][1] != '\0')) ft_replace(argv[1]..
c04 putStr putStrLn과 유사한 함수로 문자열을 받아서 I/O 작업을 리턴합니다. putStrLn 함수와의 차이점은 문자열을 출력하고 개행을 넣지않는다는 점 입니다. main = do putStr "Hey, " putStr "I'm " putStrLn "Andy!" $ runhaskell putstr_test.hs Hey, I'm Andy! 함수의 타입은 putStr :: String -> IO ()입니다. 따라서 함수 수행 결과는 아무것도 하지않는 I/O 작업에 캡슐화됩니다. atoi blockdmask.tistory.com/331 [C언어/C++] atoi, atof, atol 함수 (char* to int) 안녕하세요. BlockDMask 입니다. 오늘은 C, C++에서 문자열을 숫자(정수, ..
c04 -R CheckForbiddenSourceHeader -Wall -Wextra -Werror putStr putStrLn과 유사한 함수로 문자열을 받아서 I/O 작업을 리턴합니다. putStrLn 함수와의 차이점은 문자열을 출력하고 개행을 넣지않는다는 점 입니다. main = do putStr "Hey, " putStr "I'm " putStrLn "Andy!" $ runhaskell putstr_test.hs Hey, I'm Andy! 함수의 타입은 putStr :: String -> IO ()입니다. 따라서 함수 수행 결과는 아무것도 하지않는 I/O 작업에 캡슐화됩니다. #include #include #include voidft_putstr(char *str) { int i; i = 0; while..
c00 [gcc] Warning option 정리 gcc -Wextra -Wall -Werror a.c -o a a.c 파일을 a라는 파일로 컴파일해줌 -Werror 옵션을 사용하면 기존의 Warnning 들을 모두 error 로 인식하기 때문입니다. 출처: https://poplinux.tistory.com/tag/Werror [얼굴반반피곤합니다.] egloos.zum.com/ssulsamo/v/5247105 gcc 컴파일 옵션 (2) ---------------------------------------------------- 기본 옵션 ---------------------------------------------------- gcc -W -Wall -O2 -o test test.c -Wall 모든 모호..
c00 [gcc] Warning option 정리 gcc -Wextra -Wall -Werror a.c -o a a.c 파일을 a라는 파일로 컴파일해줌 -Werror 옵션을 사용하면 기존의 Warnning 들을 모두 error 로 인식하기 때문입니다. 출처: https://poplinux.tistory.com/tag/Werror [얼굴반반피곤합니다.] egloos.zum.com/ssulsamo/v/5247105 gcc 컴파일 옵션 (2) ---------------------------------------------------- 기본 옵션 ---------------------------------------------------- gcc -W -Wall -O2 -o test test.c -Wall 모든 모호..