What is the right way to use errno?
Answer / Ankur Mittal
In C, errno is a global variable that holds the error number of the last system error. To use it correctly, first call a function that might return an error (like fopen(), read(), write(), etc.), then check if it returned NULL or an error code, and if so, print the error message using perror("message"), which prints the string corresponding to errno.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are variables c?
How can I send mail from within a c program?
What is 'bus error'?
What is variable in c example?
write a program to display the array elements in reverse order in c language
Why do we use & in c?
what is difference between overriding and overloading?
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.
class foo { public: static int func(const char*& p) const; }; This is illegal, why?
How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;
Explain how are 16- and 32-bit numbers stored?
What is ctrl c called?