Skip to content · ⁨본문 바로가기⁩

Error handling with return codes · ⁨리턴 코드를 이용한 오류 처리⁩

English

C has no try/except

  • Some languages throw exceptions when something goes wrong. C does not have exceptions.
  • Instead, a C function reports trouble through its return value — a status code.
  • The caller checks that code after every call and decides what to do.

한국어

C에는 try/except가 없습니다

  • 일부 언어에서는 오류 발생 시 예외(exception)를 던집니다. C에는 예외가 없습니다.
  • 대신 C 함수는 반환값(return value) — 즉 상태 코드(status code)를 통해 문제를 보고합니다.
  • 호출侧(code)은 모든 호출 후 해당 코드를 확인하고 대응방식을 결정합니다.

함수가 성공 시 0, 실패 시 -1을 반환; 호출侧(code)이 코드를 검증

Handout · ⁨교재 자료⁩

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP