๋ชฉ๋ก์ ์ฒด ๊ธ (35)
๐ก
๋ฆฌ์คํธ(list) : ์ฌ๋ฌ ๊ฐ์ ์๋ฃ๊ฐ ํ ์ค๋ก ์ฐ๊ฒฐ๋ ๊ตฌ์กฐ == ์ ํ ๊ตฌ์กฐ ๋ฐฐ์ด์ ์ฌ์ฉํด ๊ตฌํ๋ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค์ด ๋ณด์ #include #include #include // ๋ ธ๋ ์์ฑ typedef struct ArrayListNodeType { intdata; } ArrayListNode; // ๋ฐฐ์ด ๋ฆฌ์คํธ ์ ์ typedef struct ArrayListType { int maxCount;// ์ต๋ ์๋ฃ ๊ฐ์ : ๋ฐฐ์ด์ ํฌ๊ธฐ int currentCount;// ํ์ฌ ์๋ฃ ๊ฐ์ ArrayListNode *pData;// ์๋ฃ ์ ์ฅ์ ์ํ 1์ฐจ์ ๋ฐฐ์ด } ArrayList; // ๋ฐฐ์ด ๋ฆฌ์คํธ ์์ฑ ArrayList *creatList(int count) { if (count maxCount = count..
๊ณผ์ ์ค๋ช - ์ ๋ ฅ๋ฐ์ ๋๋คํ ์ซ์๋ค์ ์คํ a, b ๋ฅผ ์ด์ฉํ์ฌ ์ ๋ ฌํ๋ ํจ์ ๊ตฌํ - ์ฃผ์ด์ง ๋ช ๋ น์ด๋ฅผ ์ต๋ํ ์ ์ ํ์๋ฅผ ์ฌ์ฉํ์ฌ ์ ๋ ฌํด์ผํ๋ค. ๊ตฌํ ์์ 1. ์ธ์ ๋ฐ์์ค๊ธฐ - ๋ฉ์ธํจ์์์ argv๋ก ๋ฐ์ ๋ฌธ์์ด์ ๋ฐ์์์ผ ํ๋ค - argc == 2 ์ผ๋์ argc > 2์ผ๋ - split์ ์ด์ฉํ์ฌ ๋๋ ์ค ํ ์ธ์๋ฅผ double (long long)๋ก ํ๋ณํ ํด์ค๋ค ( error chceck ๋ฅผ ์ํด) 2. Error check - ์ซ์๊ฐ ์๋ ๊ฒ์ด ๋ค์ด์ค๋ ๊ฒฝ์ฐ ./push_swap 1 a 3 4 => Error - ์ค๋ณต๋ ์ธ์๊ฐ ๋ค์ด์ค๋ ๊ฒฝ์ฐ ./push_swap 1 1 3 4 => Error - int ๋ฒ์ ์ธ์ ์ซ์๊ฐ ๋ค์ด์ค๋ ๊ฒฝ์ฐ ./push_swap 1 2147483648 => Erro..

Project overview 0. ๊ฐ์๋จธ์ ์ด๋ ํ๋์ ์ปดํจํฐ๋ก ์๋ก ๋ค๋ฅธ ์ด์์ฒด์ ๋ฅผ ์คํํ๊ณ ์ ํ ๋ ์ํํธ์จ์ด๋ก ํ๋์จ์ด ๊ธฐ๋ฅ์ ์๋ฎฌ๋ ์ด์ ํ์ฌ ์คํ 0. debain vs CentOS - ๋๋ค linux ์ด์์ฒด์ - ์ผํ ์ค๋ ๋ ๋ํ์ด ๊ณต๊ฐํ RHEL์ ๊ฐ์ ธ์์ ๋ ๋ํ์ ๋ธ๋๋์ ๋ก๊ณ ๋ง ์ ๊ฑฐํ๊ณ ๋ฐฐํฌํ ๋ฐฐํฌ๋ณธ. ๋ฌด๋ฃ ์ฌ์ฉ ๊ฐ๋ฅํ์ง๋ง ๋ฌธ์ ๋ฐ์์ ๋ ๋ํ์ด ์๋ ์ปค๋ฎค๋ํฐ ํตํด ์ง์๋๋ฏ๋ก ํจ์น๊ฐ ๋ค์ ๋๋ฆฐ ๊ฐ์ด ์์. ๋ฐ๋น์์ ์ปค๋ฎค๋ํฐ์์ ๋ง๋ค์ด์ง ๋ฐฐํฌํ์ด๋ผ ์ฌ์ฉ๋ฒ์ด ์จ๋ผ์ธ ์น์ฌ์ดํธ๋ ์ปค๋ฎค๋ํฐ์ ์์ธํ ๊ธฐ์ ๋์ด ์๋ค - ํจํค์ง ๊ด๋ฆฌ : ์ผํ ์ค๋ RPM ํฌ๋งท๊ณผ YUM/DNF ํจํค์ง ๋งค๋์ ์ฌ์ฉ. ๋ฐ๋น์์ DEB ํฌ๋งท๊ณผ dpkg/APT ๋งค๋์ ์ฌ์ฉ - ์ผํ ์ค๋ ๊ธฐ์ ์ฉ, ๋ฐ๋น์์ ๊ฐ์ธ 0. aptitede vs a..
์ฌ์ ์ง์ - ๊ฐ๋ณ ์ธ์ - printf ์ ์ ์๋ฅผ ๋ณด๋ฉด (man 3 printf) int printf(const char * restrict format, ...); ์ผ๋ก ๋์ด์๋ค ์ฌ๊ธฐ์ '...' ์ '๊ฐ๋ณ์ธ์'๋ผ๊ณ ๋ถ๋ฅธ๋ค. - ์ธ์์ ๊ฐ์์ ํ์ ์ด ๋ฏธ๋ฆฌ ์ ํด์ ธ ์์ง ์๋ค๋ ์๋ฏธ๋ก ๋๋ต์ ์ธ ๊ตฌ์กฐ๋ ์๋์ ๊ฐ๋ค. #include void foo(int a, ...) { va_list ap; va_start(ap, a) while ( ๋ชจ๋ ์ธ์๋ฅผ ์ฝ์ ๋ ๊น์ง) { va_arg(ap, ์ธ์ ํ์ ); } va_end(ap); } - va_list ap: ๊ฐ๋ณ์ธ์์ ๋ชฉ๋ก. ๊ฐ๋ณ์ธ์์ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์๋ฅผ ์ ์ฅํ๋ ํฌ์ธํฐ์ด๋ค - va_start(ap, a) : va_list ๋ก ๋ง๋ค์ด์ง ์ธ์ ๋ชฉ๋ก์ ์ฒซ ๋ฒ์งธ ์ธ์ ๋ฐ..
์ฌ์ ์ง์ - file descriptor - ํ๋ก์ธ์ค๊ฐ ํ์ผ์ ์ ๊ทผํ ๋ ํ ๋น๋์ด ํ์ผ์ ์ฐธ์กฐํ๋ index๋ผ๊ณ ์๊ฐํ์ ์์๊ฐ ์๋ ์ ์๋ก ํํ๋๋ฉฐ 0 ~ OPEN_MAX ๊น์ง์ ๊ฐ์ ๊ฐ์ง์ ์์ผ๋ฉฐ OPEN_MAX๋ ํ๋ซํผ๋ง๋ค ๋ค๋ฅด๋ค 0 - stdin 1 - stdout 2 - stderr - open ํจ์ #include int open(const char *path, int flag) path - ์ด๊ณ ์ํ๋ ํ์ผ, ๋์ผํ ๋๋ ํ ๋ฆฌ์ ์์ง ์์ผ๋ฉด ๊ฒฝ๋ก๋ ํจ๊ป ์ ์ด์ฃผ์ flag - ํ์ผ์ ์ด ๋ ์ฌ์ฉํ ์ต์ 1. O_RDONLY : ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ํ์ผ ์ด๊ธฐ 2. O_WRONLY : ์ฐ๊ธฐ ์ ์ฉ์ผ๋ก ํ์ผ ์ด๊ธฐ 3. O_RDWR : ์ฝ๊ธฐ์ ์ฐ๊ธฐ ๋ชจ๋๋ก ํ์ผ ์ด๊ธฐ *gnl ํ ์คํธ ํ ๋์๋ ์๋ณธํ์ผ์ด ํผ์๋..

14.20 ์ด๋ฆ๊ณต๊ฐ Namespace ๊ณต์ ํ๊ธฐ ๊ฐ์ ๋ธ๋ญ ์์ ํ์ ์ด ๋ฌ๋ผ๋ ์ด๋ฆ์ด ๊ฐ์ ๋ณ์๋ ์ ์ธํ ์ ์๋ค. #define _CRT_SECURE_NO_WARNINGS #include int main() { /* namespace - Identify parts of a program in which a name is recognized - You can use the same name for one variable and tag - C++: use 'namespace' to use the same identifiers in the duplicated scopes */ { int myname = 345; //double myname = 345;//Error } struct rect { double x; ..

14.9 ๊ตฌ์กฐ์ฒด์ ํ ๋น ๋ฉ๋ชจ๋ฆฌ #define _CRT_SECURE_NO_WARNINGS #include #include // strlen(), strcmp() #include // maaloc(), free() #define SLEN 81 struct namect { char* fname;//Use malloc char* lname; int letters; }; int main() { /* Dangerous usage */ struct namect p = { "Hong", "Jeong-Mo" };// ํ๋ก๊ทธ๋จ์ด ์์๋ ๋ TEXT segment์ ์ ์ฅ๋จ ์ฝ๊ธฐ ์ ์ฉ์ด๋ผ ๊ฐ์ ๋ฐฅ๊ฟ์ ์๋ค printf("%s %s\n", p.fname, p.lname); //int f1 = scanf("%[^\n]%*c", ..

13.6 ํ์ผ ์์ ์ ๊ทผ Random Access ํ์ผ์์ ์ํ๋ ์์น์ ์์ ์ ๊ทผํ๋ ์์ ์ด๋ค #define _CRT_SECURE_NO_WARNINGS #include #include /* ABCDEF ... Current position 0 and read -> A Current position 1 and read -> B ... */ int main() { int ch; long cur; FILE* fp = fopen("test.txt", "r"); cur = ftell(fp);// ํ์ฌ ์์น๋ฅผ ์๋ ค์ค๋ค. ์ด๋์ ์ฝ์ ์ค๋น๊ฐ ๋์๋๊ฐ printf("ftell() = %ld\n", cur); ch = fgetc(fp); printf("%d %c\n", ch, ch); fseek(fp, 2L, SEEK..