Command Line Arguments | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Your channel is too underrated. Your way of explaining things is unbelievable, u make everything seems so easy to understand. It would be great if u made a video on how to explain things as you do in your videos

Anas-qhhk
Автор

i started comp science major one month ago with no background in programming and your videos have been really helpful especially this one! thank you

___nia
Автор

Simple case best cases to learn from. Too many tutorials make it way too fancy and confusing. Thank you for this video

iCrazy
Автор

Your channel is my go-to when I need any information about C language! Thank you for your work, I really appreciate you.

me_dimko
Автор

I was doing my assignment. And i saw your video which is exactly what i want. Thank you so much🙂.

dhunpatel
Автор

You are a very good teacher. I hope you have videos on python and other languages. I have learned a lot from your videos. More info than an hour long tutorial

stephanek
Автор

thank you so much, you somehow explained this in the best possible way.

boonie
Автор

Very easy understanding and useful tutorial.

kuchkuch
Автор

You are a great tutor. Keep going please.

Fatih
Автор

What I don't understand is why would I use this instead of scanf, because in both cases I'm receiving an input from the user via terminal, just that in the first case is before executing the program, which also I find as a maybe issue because there's no feedback that arguments are expected or required since it can't be a printf before executing the program

germankoga
Автор

Hello. I'm on windows and I have no idea how to work like you do through the command prompt (locate and run the program, etc). Could you help me with that?

phantom
Автор

i am looking for some help. I want to do exactly what you did here. But instead of doing atoi to store the argument in an int, I want to store it inside of a char array. Let's say the input in the command line is a word. I want to put it in a char array. How do I do this?

DataStructures
Автор

Thank you so much, your video is really Great!!! So helpful with all these details !!!!

At the end of the video I was asking myself: When was it specified in this code that there will be only 3 arguments? it was like [ using the Sherlock Holmes microscope]) lol



Very interesting: because we have declared only two parameters (lower and higher) we had specified the length of the array (char *argv[]) . And here argc = 3, the second argument = lower and the third = higher.


It actually works with return (-1) instead of exit(-1)


#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
if(argc != 3)
{
printf("Two args required!\n");
//exit(-1);
return (-1);
}

int i;
int lower;
int higher;

lower = atoi(argv[1]);
higher = atoi(argv[2]);
i = lower;

printf("argc = %d\n", argc);
printf("argv[1] = %s\n", argv[1]);
printf("argv[2] = %s\n", argv[2]);

while(i <= higher)
{
printf("%d\n", i);
i++;
}
return (0);
}

zoquevil
Автор

Is char *argv[] the same as char *argv ? Is it a charcater pointer - if yes, then should just passing char *argv or char argv[] work?

ValliNayagamChokkalingam