Skip to content · ⁨Pular para o conteúdo⁩

Error handling with return codes · ⁨Tratamento de erros com códigos de retorno⁩

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.

Português

C não tem try/except

  • Alguns idiomas lançam exceções quando algo dá errado. C não tem exceções.
  • Em vez disso, uma função C reporta problemas através do seu valor de retorno — um código de status.
  • O caller verifica esse código após cada chamada e decide o que fazer.

Uma função retorna 0 em sucesso ou -1 em falha; o caller verifica o código

Handout · ⁨Material de apoio⁩

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP