Subscribe once and get notified the moment something relevant to your career is published. No spam, no noise.
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.
Command line arguments allow users to pass values to a C program during its execution from the terminal. This enables flexible and dynamic behavior based on input, making programs more useful and interactive.
int main(int argc, char *argv[]) {
// Your code here
}
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Number of arguments: %d\n", argc);
for (int i = 0; i < argc; i++) {
printf("Argument %d: %s\n", i, argv[i]);
}
return 0;
}
If compiled as ./program hello world, output will be:
Number of arguments: 3
Argument 0: ./program
Argument 1: hello
Argument 2: world
#include <stdio.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: %s <username>\n", argv[0]);
return 1;
}
printf("👋 Welcome to UdaanPath, %s!\n", argv[1]);
return 0;
}
This program greets the user with their name passed as a command-line argument. Example: ./welcome Kuldeep
atoi(), atof() to convert them into numbers.argv[0] to get the program name.#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if (argc < 3) {
printf("Usage: %s num1 num2\n", argv[0]);
return 1;
}
int a = atoi(argv[1]);
int b = atoi(argv[2]);
printf("Sum: %d\n", a + b);
return 0;
}
argc and argv[] to receive command-line arguments.In the next and final chapter, we’ll learn about Error Handling and errno — how to gracefully handle errors and check system-level error codes.