hello great video as always, I would just like to point out for anyone who wants to pass a string containing a space inside of it as an argument, the command line doesn't actually split by spaces (4:26), you can actually use speech marks like this: Tutorial.exe test "test2 and test3" test4 And this would return argv[0]: Tutorial.exe argv[1]: test argv[2]: test2 and test3 argv[3]: test4
Thank you SO MUCH for this video. As a first semester computer engineering student, videos like this are SO freaking valuable to noobs like me. The fact that you are uploading such interesting and well explained videos should be acknowledge. Thank you so much, good sir.
I like the way you explain, step by step in a coding environment, instead of doing so only theoretically. Your videos really helped me. Thanks and keep it up!
My friend you are simply an excellent teacher. I am very appreciative of these C tutorials. I have purchased a C course on Udemy which happens to be taught by another Italian guy. Between the two of you I will be fluent in no time.
bro seriously when i saw you first time i was like you have million subscriber but when i saw your subs it really didn't matched post video more frequently you'll quickly get more subscriber you are so good
very very helpfull thank you - thought even with that I had some problems because I tried to pass via cmd name of the file that the program would use but for whatever reason it didn't work and after like 10h I realised that the files aren't where the .exe is so I needed to send their full path to them instead of just the name of the file
Just declare it global and set it in main, something like this, but maybe with more validation for converting the argv elements to the needed type: int globalVar; int main(int argc, char* argv[]) { if (argc > 1) { globalVar = (int) strtol(argv[1], NULL, 0); } }
May you please make a session explaining the concept of the command-line argument as the concept of double-pointer and how to use it in a function call?
I wrote the exact same code, tried it on Win 10 and VM Linux Ubuntu with different IDEs and editors(CodeLite and VS Code) and with different compilers(MinGW64, gcc, clang). They build without errors and warnings, and when i don't pass any integer into command line all is good - result = 1. But when i pass some integers, either program crashes on Win 10 or i get result = 0 on Ubuntu . But argv's at the begining print correctly. On the debug session with CodeLite, i get error "Program received signal SIGSEGV" on the line where x is assigned using strtol function. Having a hard time to get it..
argv is an array of pointers to char. argv[i] gets the i-th element in that array and dereferences it leaving us with a pointer to char (which is considered a string). argv[i] is short-hand for *(argv + i) so, in fact, we are using *
Hi there: thank you for your video! It is truly very useful. Yet I have two questions remain: First, since argc is in the argument, why don't we need to input an integer in the command line? Since technically the main function has two inputs: the integer argc and the string array argv, right? Second, is there other ways to do command line argument other than int main( int argc, char* argv[]) ? What I mean is, is this argument a convention and never should have been changed? Is it possible if, let's say I write int main(int a, int b) ? Thank you!
1) You don't need to type the value of argc in the command line because the command line processor takes care of that for you 2) Yes, it's a convention and there really isn't any other way of doing it (that's not hacky at least)
hey thank you for the great content, your videos are really helpful. I have two questions, what is the best way to convert an int array to array of strings char* newargv [] so I can pass it to a new program using execve() system call, could I use type casting to do it and is using sprintf() a good way of doing it. The second questions is it possible to pass arguments from parent process to the child process using execve(), my professor is asking us to do it for the assignment and I can't find any useful source about this, I know that you should use a pipe to share data between process but our professor want us to do it using execve(). Thank you alot for the time and help.
1) You can't use type casting for it. sprintf() used in a loop is a good solution though 2) There are these videos regarding your question: code-vault.net/course/46qpfr4tkz:1603732431896/lesson/43zvcsz6o1:1603732432539 code-vault.net/course/46qpfr4tkz:1603732431896/lesson/phac6gv4cy:1603733529763
hello great video as always, I would just like to point out for anyone who wants to pass a string containing a space inside of it as an argument, the command line doesn't actually split by spaces (4:26), you can actually use speech marks like this: Tutorial.exe test "test2 and test3" test4
And this would return
argv[0]: Tutorial.exe
argv[1]: test
argv[2]: test2 and test3
argv[3]: test4
Very useful video....especially I like last few minutes about where these command line arguments are getting used in reality.... Keep up the good work
Thank you SO MUCH for this video. As a first semester computer engineering student, videos like this are SO freaking valuable to noobs like me. The fact that you are uploading such interesting and well explained videos should be acknowledge. Thank you so much, good sir.
I like the way you explain, step by step in a coding environment, instead of doing so only theoretically. Your videos really helped me. Thanks and keep it up!
Your channel is Babel's library for computer science students
The best explanation I've seen on this topic, that seems so cryptic to learn anywhere else.
One of the greatest educators on this platform hands down.
You definitely know what you are doing and spreading confidence when you are explaining. Thank you so much for such a clear and fluent explanation!
Very well explained ,this has been quite useful ,I keep coming back now
My friend you are simply an excellent teacher. I am very appreciative of these C tutorials. I have purchased a C course on Udemy which happens to be taught by another Italian guy. Between the two of you I will be fluent in no time.
You're the goat. You explain everything so clearly, thank you.
I Just Want To Thank You And Keep Doing What You Are Doing !
You Will Be Of Great Help To A Lot Of People,As You Are Now !
bro seriously when i saw you first time i was like you have million subscriber but when i saw your subs it really didn't matched post video more frequently you'll quickly get more subscriber you are so good
really solid and easy to understand sir, thanks for you tutorial
Thank u so so much sir. Preparing for my interview's first round at multicoreware and this helped me so much. Love from INDIA ❤️🇮🇳
Beautiful tutorial. Explained perfectly thank you so much.
Omg, I've been pulling hairs trying to understand what's going on. Thank you!!!
Thank you for providing such knowledgeable content !
this video was very helpful when I was doing my cs homework
thank you :)
I am will comment in your every video you just continue 🙏 making that lovely content my friend.
thank you for all the videos, they have really helped me a lot
Thanks a lot! Very clear and simple.
Awww your tutorial is really easy to understand
Phenomenal video, thank you.
Thank you for your explanation :)
very helpful video. Thank you so much.
Clear and Concise.
Thankyou
Very clear, you deserve "like" and subscribe
there more I learn c the more I love it
continue making thas awesome content, love it. talk about pointers please
very very helpfull thank you - thought even with that I had some problems because I tried to pass via cmd name of the file that the program would use but for whatever reason it didn't work and after like 10h I realised that the files aren't where the .exe is so I needed to send their full path to them instead of just the name of the file
this helped me a lot thnx for explaining :)
clear and concise! great video!
Very helpful and very unique content ❤️
Keep it going very helpful
Perfect example thx.
So helpful! I have a question though, how do you set global variables based on command line arguments? Thank you!
Just declare it global and set it in main, something like this, but maybe with more validation for converting the argv elements to the needed type:
int globalVar;
int main(int argc, char* argv[]) {
if (argc > 1) {
globalVar = (int) strtol(argv[1], NULL, 0);
}
}
May you please make a session explaining the concept of the command-line argument as the concept of double-pointer and how to use it in a function call?
pretty useful thanks, keep it up!
You are the best bro keet it up I subscribed
thank you so much
Can we also use atoi() instead of strtol() for converting string to int?
No. It has a lot of issues. I really suggest you use strtol. I have some videos regarding that: code-vault.net/lesson/ppdf96xhwi:1603733526989
sorry what ide are you using?
In this video I'm using Visual Studio Community Edition
I wrote the exact same code, tried it on Win 10 and VM Linux Ubuntu with different IDEs and editors(CodeLite and VS Code) and with different compilers(MinGW64, gcc, clang). They build without errors and warnings, and when i don't pass any integer into command line all is good - result = 1. But when i pass some integers, either program crashes on Win 10 or i get result = 0 on Ubuntu . But argv's at the begining print correctly. On the debug session with CodeLite, i get error "Program received signal SIGSEGV" on the line where x is assigned using strtol function. Having a hard time to get it..
Huh... can you share the code please? I can look into it
But in printf argv[i] when we are using it is giving the address of the string why are we not using * in front of argv[i]?
argv is an array of pointers to char. argv[i] gets the i-th element in that array and dereferences it leaving us with a pointer to char (which is considered a string).
argv[i] is short-hand for *(argv + i) so, in fact, we are using *
all that I can say is...thank you so much bruh
Great sir.
Sir can we create a GUI by using C.
Yes, of course. Here's the documentation for Win32 API for Windows: learn.microsoft.com/en-us/windows/win32/apiindex/windows-api-list
Hi there: thank you for your video! It is truly very useful. Yet I have two questions remain: First, since argc is in the argument, why don't we need to input an integer in the command line? Since technically the main function has two inputs: the integer argc and the string array argv, right? Second, is there other ways to do command line argument other than int main( int argc, char* argv[]) ? What I mean is, is this argument a convention and never should have been changed? Is it possible if, let's say I write int main(int a, int b) ? Thank you!
1) You don't need to type the value of argc in the command line because the command line processor takes care of that for you
2) Yes, it's a convention and there really isn't any other way of doing it (that's not hacky at least)
@@CodeVault Thank you so much for your explanation! It's truly very helpful.
so helpful, thank you!!!!
Great Video!
Do you know if it's possible to debug on codeblocks while using command line arguments? I haven't been able to do it.
In the top bar: Project -> Set programs' arguments. Make sure you add them to the proper target (most likely Debug).
hey thank you for the great content, your videos are really helpful.
I have two questions, what is the best way to convert an int array to array of strings char* newargv [] so I can pass it to a new program using execve() system call, could I use type casting to do it and is using sprintf() a good way of doing it.
The second questions is it possible to pass arguments from parent process to the child process using execve(), my professor is asking us to do it for the assignment and I can't find any useful source about this, I know that you should use a pipe to share data between process but our professor want us to do it using execve().
Thank you alot for the time and help.
1) You can't use type casting for it. sprintf() used in a loop is a good solution though
2) There are these videos regarding your question:
code-vault.net/course/46qpfr4tkz:1603732431896/lesson/43zvcsz6o1:1603732432539
code-vault.net/course/46qpfr4tkz:1603732431896/lesson/phac6gv4cy:1603733529763
My program will not allow me to pass in command line arguments. Is there something wrong with my compiler?
How are you running your program?
great video thank you very much you beautiful fella :)
my programme gives always this error how can I fix it I can not write a argument on terminal The term 'a' is not recognized as the name of a cmdlet
"a" is the name of your executable?
lets say i want to pass a txt file as an argument through terminal. Do i follow the same procedure?
Yea, you'll have the path of the file at argv[1]
Cool 🎉
why tutorial.exe is first argument when your file name is main.c ?
That's just how Visual Studio compiles the project. The executable is the name of the project, which, in my case, is "Tutorial"
Ahh so that’s what string[] args is
You said that this is c++ programming, but why you use commands from C?
That's just for explanation, you can use C++ functions (like cout) if you want to. This video focuses on argc and argv and what they contain.
Danke
Xin cảm ơn
🥰🥰🥰🥰🥰🥰🥰🥰🥰
😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘
Sank yu