Start your programming journey with one of the most powerful and foundational languages — C. This comprehensive course is designed for absolute beginners as well as intermediate learners who want to build a solid understanding of programming using the C language. Whether you're preparing for college-level programming, cracking technical interviews, or planning to explore systems or embedded development, this course covers everything step-by-step. Through hands-on examples, real-world practice problems, and structured explanations, you’ll learn how to write clean and efficient C code — from your first printf() to advanced data structures and memory management.
errno in C
Error handling in C is essential to ensure a program doesn't crash or behave unexpectedly. C provides basic error reporting through return values and advanced error information using the errno global variable.
fopen() failure)malloc() returns NULL)FILE *fp = fopen("example.txt", "r");
if (fp == NULL) {
printf("Error opening file.\n");
}
errno
errno is a global variable defined in <errno.h> that stores the last error code when a library function fails.
#include <stdio.h>
#include <errno.h>
int main() {
FILE *fp = fopen("missing.txt", "r");
if (fp == NULL) {
printf("Error code: %d\n", errno);
perror("File opening failed");
}
return 0;
}
FILE *scoreFile = fopen("scores.txt", "r");
if (scoreFile == NULL) {
perror("UdaanPath Error");
printf("Use 'Contact Us' if the file is missing.\n");
return 1;
}
perror("msg"): Prints system error with your messagestrerror(errno): Returns a string describing the error#include <string.h>
#include <errno.h>
int main() {
FILE *f = fopen("abc.txt", "r");
if (!f) {
printf("Error: %s\n", strerror(errno));
}
return 0;
}
errno Values| Code | Constant | Meaning |
|---|---|---|
| 2 | ENOENT | No such file or directory |
| 12 | ENOMEM | Not enough space |
| 13 | EACCES | Permission denied |
errno.malloc() to allocate a huge array and check for NULL.strerror(errno).errno helps identify specific issues after failure.perror() and strerror() provide detailed error messages.Now that you've completed the fundamentals, it's time to level up! In the next section, we'll begin with advanced concepts starting with Bitwise Operators and Bit Manipulation — powerful tools for performance-oriented C programming, system-level logic, and embedded development.