Exercise 00 : ft_print_program_name ํ์ด → argc, argv๋ฅผ ์ดํดํ๋ ๋ฌธ์ . argv[0]๋ ํ๋ก๊ทธ๋จ๋ช
์์ ์ดํดํ๋ ๋ฌธ์ . ์ฃผ์ํ ์ฌํญ 1)argc์ ๊ฐ์ ์ฌ์ฉํ์ง ์์ผ๋ฉด, ์๋ฌ๊ฐ ๋จ๊ธฐ ๋๋ฌธ์ ๊ตณ์ด ์ธ ํ์ ์๋ ์กฐ๊ฑด์ด์ง๋ง, argc ! = 0์ผ๋๋ฅผ ๋ฃ์ด์คฌ์. 2)\0 ์ผ๋ก ๋ค์ ์ค๋ก ๋๊ฒจ์ค์ผ ํจ. ์ฝ๋ #include voidft_putstr(char *str) { intlen; len = 0; while (str[len]) ++len; write(1, str, len); } intmain(int argc, char **argv) { if (argc != 0) ft_putstr(argv[0]); write(1, "\\n", 1); return (0); } Exerci..
Exercise 00 : ft_iterative_factorial ๋ฌธ์ ํ์ด ํฉํ ๋ฆฌ์ ํจ์๋ฅผ ๋ฐ๋ณต ํจ์๋ก ๊ตฌํํ๊ธฐ ์ธ์๊ฐ ์ ํจํ์ง ์์ผ๋ฉด 0 ๋ฐํ = ์์์ผ๋๋ 0๋ฐํ ์ค๋ฒํ๋ก์ฐ๋ ์ฒ๋ฆฌํ๋ฉด ์๋จ.(ํ/์ ์ค์ญ ์ฃผ์) cf) 0! = 1 ์ฝ๋ intft_iterative_factorial(int nb) { intfactorial; intindex; if (nb < 0) return (0); index = 1; factorial = 1; while (index < nb + 1) factorial = factorial * index++; return (factorial); } Exercise 01 : ft_recursive_factorial ๋ฌธ์ ํ์ด → ํฉํ ๋ฆฌ์ผ ํจ์๋ฅผ ์ฌ๊ทํจ์๋ก ๊ตฌํํ๊ธฐ ์ธ์๊ฐ ์ ํจํ์ง ์..
Exercise 00 : ft_strlen ๋ฌธ์ ํ์ด → (์ด์ ๋ฌธ์ ์ ๋์ผํ ๋ฌธ์ ) ๋ฌธ์์ด ๋ด์ ๋ฌธ์์ ๊ฐ์๋ฅผ ์ธ์ด ๋ฐํํ๋ ํจ์ ์์ฑ ์ฝ๋ #include intft_strlen(char *str) { inti; i = 0; while (str[i]) ++i; return (i); } Exercise 01 : ft_putstr ๋ฌธ์ ํ์ด → (์ด์ ๋ฌธ์ ์ ๋์ผํ ๋ฌธ์ ) ๋ฌธ์์ด์ ์ถ๋ ฅํ๋ ํจ์ ์์ฑ ์ฝ๋ #include voidft_putchar(char c) { write(1, &c, 1); } voidft_putstr(char *str) { while (*str) ft_putchar(*(str++)); } Exercise 02 : ft_putnbr ๋ฌธ์ ํ์ด → (์ด์ ๋ฌธ์ ์ ๋์ผํ ๋ฌธ์ ) ๋งค๊ฐ ๋ณ..
Exercise 00 : ft_strcmp intft_strcmp(char *s1, char *s2) { while (*s1 || *s2) { if (*s1 != *s2) return (*s1 - *s2); //s1์ด ๋ ํฌ๋ฉด ์์, s2๊ฐ ๋ ํฌ๋ฉด ์์ ์ถ๋ ฅ ++s1; ++s2; } return (0); } :strcmp(๋ฌธ์์ด1, ๋ฌธ์์ด2) : ์ธ์๋ก ์ ๋ฌ๋ ๋๊ฐ์ ๋ฌธ์์ด์ ๋น๊ตํ๋ ํจ์. =[compare strings] return : ์์ ๋ฐํ (str 1 str2) cf)๊ฐ ๋ฌธ์ ๋น๊ต ๊ธฐ์ค์ ASCII ์ฝ๋์. ๊ถ๊ธํ ์ . while(*s1 || *s2) ํ๋ ธ์. Exercise 01 : ft_strncmp #include..
Exercise 00 : ft_strcpy char*ft_strcpy(char *dest, char *src) { int i; i = 0; while (src[i]='\\0') { dest[i] = src[i]; ++i; } dest[i] = 0; return (dest); } strcpyํจ์ ๊ตฌํํ๊ธฐ โผ strcpy ํจ์๋? strcpy(๋ณต์ฌ๋ฅผ ๋ฐ์ ๋์์ ์์์ฃผ์, ์๋ณธ์ ์์ ์ฃผ์) : ๋์ ๋ฌธ์์ด์ ํฌ์ธํฐ๋ฅผ ๋ฐํ =string copy์ ์ค์ ํํ์ผ๋ก ๋ฌธ์์ด์ ๋ณต์ฌํ๋ค๋ ๋ป. ์ด๋ค ๋ณ์(๋ฌธ์์ด ์์)์ ์ ์ฅ๋์ด์๋ ๋ฌธ์์ด์ ๋ค๋ฅธ ๋ณ์(๋ฉ๋ชจ๋ฆฌ)์ ๋ณต์ฌํ ๋ ์ฌ์ฉํ๋ค. cf) a[]=’banana’ //100๋ฒ์ง์ ์ ์ฅ๋์ด ์๋ค๊ณ ํ์. b[]=’kiwi’๋ผ๊ณ ํ ๋, //200๋ฒ์ง์ ์ ์ฅ๋์ด ์๋ค๊ณ ..
Exercise 00 : ft.c voidft_ft(int *nbr) { *nbr = 42; } Exercise 01 : ft_ultimate_ft.c voidft_ultimate_ft(int *********nbr) { *********nbr = 42; } Exercise 02 : ft_swap.c voidft_swap(int *a, int *b) { inttmp; tmp = *a; *a = *b; *b = tmp; } Exercise 03 : ft_div_mod.c voidft_div_mod(int a, int b, int *div, int *mod) { *div = a / b; *mod = a % b; } Exercise 04 : fl_ultimate_div_mod.c voidft_ultimate_..
Exercise 00 : ft_putchar write ํจ์ ์ฌ์ฉํ๊ธฐ #include voidft_putchar(char c) { write(1, &c, 1); } ์ธ์ file descriptor :n ํ์ผ์ ์ธ ๋ฐ์ดํฐ์ ํฌ๊ธฐ fd : 0(์
๋ ฅ), 1(์ถ๋ ฅ), 2(์๋ฌ) nbytes : ์ฐ๊ณ ์ํ๋ ๋ฐ์ดํฐ์ ๊ธธ์ด๋ก buf์ ๊ธธ์ด๋ณด๋ค ๊ธธ์ด์ ์๋จ. write ํจ์๋ ๋ฌธ์ํ๋ง ๋ฐ์ ์ ์์. Exercise 01 : ft__print__alphabet → a ๋ถํฐ z ๊น์ง ํ ์ค๋ก ํ์ํ๋ ํจ์ #include voidft_print_alphabet(void) { charc; c = 'a'; while (c = 'a') { write(1, &c, 1); --c; } } ๋ฌธ์๋ผ๋ฆฌ์ ๋์ ๋น๊ต = ์์คํค ์ฝ๋ ..
Exercise 01 : print_groups groups $FT_USER | sed 's/ /,/g' | tr -d '\\n' groups๋ฅผ ์ด์ฉํ ์ฝ๋ Exercise 02 : find_sh find . -type f -name "*.sh" -exec basename {} \\; | sed 's/.sh$//g' find . -type f -name "*.sh" -exec basename {} .sh \\; -> basename์ผ๋ก ํ๋ฒ์ ๊ฒฝ๋ก๋ช
๊ณผ ํ์ฅ์๋ฅผ ์ง์ธ ์ ์๋ ์ฝ๋. type f : ์กฐ๊ฑด์ ๋ง์กฑํ๋ ํ์ผ์ ์ฐพ๋ ์ต์
์กฐ๊ฑด [ํ์ผ์ ์ฐพ์๋ผ]๋ฅผ ๋ง์กฑ์ํด find : ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ๋ฅผ ๊ฒ์ํ ๋ ์ฌ์ฉํ๋ ๋ช
๋ น์ด . : ์กฐ๊ฑด [ํ์ฌ ๋๋ ํ ๋ฆฌ์ ๊ทธ ํ์ ๋๋ ํ ๋ฆฌ์์ ์ฐพ์๋ผ] name “*.sh” ..
Exercise 06 : gitignore .gitignore : Github ์๊ฒฉ ์๋ฒ์ ๋ก์ปฌ ํ๋ก์ ํธ๋ฅผ ์ฌ๋ฆด ๋ ๋ถํ์ํ ๋ก๊ทธ ํ์ผ๋ค์ ์
๋ฐ์ดํธ ํ์ง ์๋๋ก ๋ฌด์ํ ํ์ผ๋ค ๋ชฉ๋ก์ ๋ง๋๋ ๊ฒ. .gitignore ํ์ผ ๋ง๋๋ ๋ฒ : touch .gitignore cf)Git Bash์ ๋ค์ด๊ฐ .git์ด ์๋ ๋ด git ํ๋ก์ ํธ์ ๋ฃจํธ ๋๋ ํฐ๋ฆฌ์ cd ๋ช
๋ น์ด๋ฅผ ํตํด ๋ค์ด๊ฐ ํ ์์ ๊ฐ์ ๋ช
๋ น์ด๋ฅผ ์คํํด .gitignore ํ์ผ์ ๋ง๋ค์ด์ค๋ค. ์ฌ์ค ๋ฉ๋ชจ์ฅ์ผ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ๋ ์์ง๋ง “.txt”๊ฐ ๋ค์ ๋ถ์ ์ฐ๋ ค ๋๋ฌธ์ ์ด ๋ฐฉ๋ฒ์ ๋ ์ถ์ฒํ๋ค. .gitignore์ ๋ฐ๋์ ๋ฃจํธ ๋๋ ํฐ๋ฆฌ์ ์์ด์ผ ํ๋ค. #!/bin/bash #.shํ์ผ์ ์คํํ ์ ์๋๋ก ํ๊ธฐ ์ํ ์ฝ๋ git ls-files --others..