Skip to Content
우아한 C언어 코딩 패턴
book

우아한 C언어 코딩 패턴

by Christoper Preschem, 정기훈(Jung Ki Hun)
April 2024
Beginner to intermediate
364 pages
7h 2m
Korean
Insight
Content preview from 우아한 C언어 코딩 패턴
Fluent
84
󻱴󽴔󽴔󺼣󺽷󺹻󽴔󺇏󺹻
이제 텍스트는 스택이 아닌 정적 메모리에 상주하게 된다. 이 작업을 수행할
때 기억해야 할 점은 변수는 한 번만 만드는데 그 값은 계속 유지된다는 것이
다(함수에 여러 차례 진입해도 마찬가지다). 다중 스레드 시스템에서는 이 변
수에 접근할 때 상호 배제(mutual exclusion)를 보장해야 한다는 이슈가 발생
할 수 있다.
현재는 다중 스레스 시스템을 사용하지 않는다. 그러나 시스템 요구 사항이
변경되었다. 파일에서 텍스트를 읽고 암호화한 다음 암호화된 텍스트를 표시
하려 한다. 텍스트가 얼마나 길어질지 알 수 없으며, 굉장히 길 수도 있다. 따
라서 여러분은 동적 할당을 도입하기로 결정하였다.
void encryptCaesarText()
{
/*
파일
오픈
(
단순하게
하기
위해
오류
처리
부분은
생략
) */
FILE* f
=
fopen("my
-
file.txt", "r");
/*
파일
길이
획득
*/
fseek(f, 0, SEEK
_
END);
int size
=
ftell(f);
/*
버퍼
할당
*/
char* text
=
malloc(size);
...
}
그러면, 이 코드는 어떻게 계속 진행되어야 할까? 힙에 텍스트를 할당하긴 했
는데, 메모리를 어떻게 클린업하면 좋을까? 먼저 이 메모리를 클린업할 수 있
는 다른 존재가 있음을 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AI를 위한 필수 수학

AI를 위한 필수 수학

할라 넬슨
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에
클라우드 네이티브 애플리케이션 디자인 패턴

클라우드 네이티브 애플리케이션 디자인 패턴

카순 인드라시리, 스리스칸다라자 수호티얀

Publisher Resources

ISBN: 9788966264742