일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Cleancode
- graph
- 정수론
- Python
- Math
- 생활코딩
- JavaScript
- web
- Algospot
- String
- php
- 따라하며 배우는 C언어
- C
- dfs
- 종만북
- programmers
- sorting
- udemy
- C언어
- 백준
- 따라하면서 배우는 C언어
- BASIC
- greedy
- server
- BFS
- BOJ
- DP
- 인프런
- 따배씨
- Algorithm
- Today
- Total
목록따라하면서 배우는 C언어 (121)
몽상실현개발주의

따배씨 - 따라하며 배우는 C언어 14강 구조체_2 14.15 공용체 Union 의 원리 #include int main() { /* Union - Store different data types in the same momory space - Strucutre vs Union */ union my_union { int i; double d; char c; }; union my_union uni; printf("%zd\n", sizeof(union my_union)); // 8 printf("%lld\n", (long long)&uni); // 140732920755232 printf("%lld %lld %lld\n", (long long)&uni.i, (long long)&uni.d, (long lon..

따배씨 - 따라하며 배우는 C언어 14강 구조체_2 14.13 구조체의 배열을 사용하는 함수 #include #define SLEN 101 struct book { char name[SLEN]; char author[SLEN]; }; void print_books(const struct book books[], int n); int main() { struct book my_books[3]; // = {"The Great Gatsby", "F. Scott Fitzgerald"},...}; my_books[0] = (struct book){"The Great Gatsby", "F. Scott Fitzgerald"}; my_books[1] = (struct book){"Hamlet", "William Sha..

따배씨 - 따라하며 배우는 C언어 14강 구조체_2 14.12 익명 구조체 Anonymous Structures #include struct names { char first[20]; char last[20]; }; struct person { int id; struct names name; // nested strucutre member }; struct person2 { int id; struct { char first[20]; char last[20]; }; // anomymous strucutre }; int main() { struct person ted = { 123, {"Bill", "Gates"}}; struct person ted3 = { 125, {"Robert", "Hand"}}; p..

따배씨 - 따라하며 배우는 C언어 14강 구조체_2 14.11 신축성 있는 배열 멤버 Flexible Array Members #include #include int main() { /* Flexible array member (struct hack in GCC) // 지금은 표준 */ struct flex { size_t count; double average; double values[]; // flexible array member (last member!) // 구조체가 저장되는 메모리 구조상, flexible array 변수 위치를 마지막으로 두어야 사용하기 편함 }; const size_t n = 3; struct flex* pf = (struct flex*)malloc(sizeof(struc..

따배씨 - 따라하며 배우는 C언어 14강 구조체_1 14.9 구조체와 할당 메모리 #include #include // strlen(), strcmp() #define SLEN 81 struct namect { char* fname; // Use malloc() char* lname; // Use malloc() int letters; }; int main() { struct namect p = {"Jeong-Mo", "Hong"}; printf("%s %s\n", p.fname, p.lname); /* Dangerous usage */ int f1 = scanf("%[^\n]%*c", p.lname); printf("%s %s\n", p.lname, p.fname); return 0; } struct ..

따배씨 - 따라하며 배우는 C언어 13강 파일 입출력 13.4 텍스트 파일 모드 스트링과 다양한 입출력 함수들 fprintf() fscanf() fgets() fputs() #include #include #include #define MAX 31 int main(void){ FILE * fp; char words[MAX] = {'\0'}; const char* filename = "record.txt"; /* fopne() mode strings for text fiels - r : reading - w : creating-and-writing or over-writing - a : appending or creating-and-writing - r+ : both rading and writing - ..

따배씨 - 따라하며 배우는 C언어 13강 파일 입출력 13.1 파일 입출력의 작동 원리 프로그램 실행시, 프로그램과 운영체제 사이의 3가지 stream 이 열림 stdout : standard Output stderr : standard Error, 긴급 출력 stdin : standard Input Buffered IO Stream 버터를 사용하는 입출력 stream 입/출력 시 buffere 에 저장하였다가 한번에 처리하여 속도를 개선 File Stream C 언어에서 파일 입/출력을 stream 으로 처리 c 언어로 작성된 프로그램의 파일 스트림은 2가지 mode 를 사용 text file IO stream binary file IO stream Text Files : 사람이 읽을 수 있는 문자가 ..

따배씨 - 따라하며 배우는 C언어 12강 Storage Classes, Linkage and Memory Management 12.19 멀티 쓰레딩 Multi-Threading Process : 실행중에 있는 프로그램 Process 내부에는 최소 하나의 Thread 를 가지고 있음, 실제로 Thread 단위로 스케줄링을 함 하드디스크에 있는 프로그램을 실행하면, 실행을 위한 메모리 할당이 이루어지고, 할당된 메모리 공간으로 바이너리 코드가 올가가게 됨. 이 순간부터 Process 라고 불림 Thread : Process 내에서 실행되는 여러 흐름의 단위 Process 의 특정한 수행 경로, 할당 받은 지원을 이용하는 실행 단위 Thread 는 Process 내에서 각각 Stack 만 따로 할당받고, Co..