C

errno & perror

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Kur një funksion i sistemit dështon (p.sh. fopen), ai e vendos numrin e gabimit në variablën globale errno. perror() e shfaq këtë gabim me fjalë — p.sh. „No such file or directory“ — që ta kuptosh menjëhere çfarë shkoi keq.

EnglishEN

When a system function fails (like fopen), it puts the error number in the global variable errno. perror() prints that error in words — like “No such file or directory” — so you understand straight away what went wrong.

Si ta mendosh

Si drita e motorit në panelin e veturës, bashkë me kodin e gabimit që mekaniku e lexon.

Lexoje në anglisht

Like the engine light on a car dashboard, plus the error code the mechanic reads.

Shembull kodic

#include <errno.h>
FILE *f = fopen("s-ekziston.txt", "r");
if (!f) perror("fopen");   // fopen: No such file or directory

Terma të lidhur