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언어 코딩 패턴
C
5
󻞳󼩘󽴔󻫗󻳫
󻞳󼩘󽴔󻫗󻳫
어떤 파일에서 특정 키워드들에 대한 구문 분석을 시행하고 탐색된 키워드 정
보를 반환하는 함수를 구현하고자 한다.
C에서 오류 상황을 나타내는 표준적인 방법은 함수의 반환값을 통해 오류
정보를 제공하는 것이다. 오류에 대한 추가 정보가 필요한 경우, 전통적인 C 함
수는 종종
errno
변수(errno.h 참조)를 설정하여 특정 오류 코드로 지정한다.
이렇게 하면 호출자는
errno
를 통해 오류 정보를 확인할 수 있다.
하지만, 다음과 같은 코드는 굳이 상세한 오류 정보까지는 필요하지 않기 때
문에
errno
대신 반환값을 사용한다. 다음은 예제 코드 초기 버전이다.
int parseFile(char* file
_
name)
{
int return
_
value
=
ERROR;
FILE* file
_
pointer
=
0;
char* buffer
=
0;
if(file
_
name!
=
NULL)
{
if(file
_
pointer
=
fopen(file
_
name, "r"))
{
if(buffer
=
malloc(BUFFER
_
SIZE))
{
/*
파일
내용에
대한
구문
분석
*/
return
_
value
=
NO
_
KEYWORD
_
FOUND;
while(fgets(buffer, BUFFER
_
SIZE, file
_
pointer)!
=
NULL)
{
if(strcmp("KEYWORD ...
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

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

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

오현석, 해리 퍼시벌, 밥 그레고리
클라우드 네이티브 애플리케이션 디자인 패턴

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

카순 인드라시리, 스리스칸다라자 수호티얀
개발 7년차, 매니저 1일차

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

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9788966264742