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

  • بعض اللغات تُلقِ استثناءات عند حدوث خطأ. C لا تحتوي على استثناءات.
  • بدلاً من ذلك، تُبلغ دالة C عن المشكلة عبر قيمة الإرجاع — رمز حالة.
  • المُدْعِي يتحقق من هذا الرمز بعد كل استدعاء ويقرر ما يجب فعله.

الدالة تُرجع 0 بنجاح أو -1 بالفشل؛ المُدْعِي يتحقق من الرمز

Handout · ⁨ورقة عمل⁩

Log in or create account · ⁨تسجيل الدخول أو إنشاء حساب⁩

IGCSE, A-Level & AP