What does int argc, char* argv[] mean?

Sdílet
Vložit
  • čas přidán 9. 01. 2015
  • In this tutorial I explain the meaning of the argc and argv variables that are often passed in the main function of a C or C++ program.
    Want to learn C++? I highly recommend this book amzn.to/1PftaSt
    Donate - bit.ly/17vCDFx
    STILL NEED MORE HELP?
    Connect one-on-one with a Programming Tutor. Click the link below:
    trk.justanswer.com/aff_c?offe...
    :)

Komentáře • 309

  • @hass89
    @hass89 Před 8 lety +376

    Argc is ARGument Count and and argv is ARGument Vector.

    • @felipemartin8255
      @felipemartin8255 Před 7 lety +13

      And "Vector reffers to an array, not a C++ or Euclidean vector"
      See reference here:
      www.cplusplus.com/articles/DEN36Up4/
      Ps.: Although the name of the site be cpluplus.com, all the teachings contained there are compatible with C.

    • @dronebee
      @dronebee Před 7 lety +7

      Kingsman is KINGdom's MAN.

    • @lovemoreanime6981
      @lovemoreanime6981 Před 6 lety +1

      is he managing directory by programming ?

    • @hetaeramancer
      @hetaeramancer Před 3 lety +2

      what are counts and vectors in C?

    • @Phantom-fi8sc
      @Phantom-fi8sc Před 3 lety +1

      @@hetaeramancer I tried to print the argv it shows the path of some designated file

  • @Rookwie
    @Rookwie Před rokem +13

    I couldn't understand this for so long, I read some stack overflow, watched some tutorials, looked up some problems and nothing helped until I found this video, great explanation!! Feels way better to finally understand this

  • @reneezmp
    @reneezmp Před 2 lety +38

    Hey Paul, I'd like you to thank for putting your energy into making this tutorial. It was really enlightening and it made me comprehend the concept much better. Keep up the awesome job.

  • @mikroelektro
    @mikroelektro Před 8 lety +61

    Never understood it until I saw you video 👌👍

  • @86jam184
    @86jam184 Před rokem +1

    I want this guy to explain literally everything in my life

  • @mustafaadam9697
    @mustafaadam9697 Před 8 lety +196

    You CAN declare a variable inside a for loop in C. Just use C99 or C11.

    • @nicolareiman9687
      @nicolareiman9687 Před 4 lety +15

      @Artem Katerynych It's a standard that the compilers have to follow. it's not a version

    • @nicolareiman9687
      @nicolareiman9687 Před 4 lety +16

      @Artem Katerynych Well technically we're both late.

    • @316monisbandey3
      @316monisbandey3 Před 3 lety

      @@nicolareiman9687 yes

    • @NateROCKS112
      @NateROCKS112 Před 2 lety +1

      @@nicolareiman9687 it is a version, if you define it to be "[a] particular form or variation of an earlier or original type" (American Heritage Dictionary, 5th Edition). It's not a version of a particular C implementation -- such as a compiler or standard library -- but it is a version of the C language.
      Edit: And I'm also a year late, lol.

    • @redemedy8602
      @redemedy8602 Před 2 lety +1

      i was about to. To be honest i dont get why ppl dont use c99. I just dont get it. If anyone can explain i will apreciate it alot

  • @tonyblue5057
    @tonyblue5057 Před rokem +1

    You are literally the best my professor expected most of us to know c and it took me about 2 weeks on an assignment because i couldn't figure this out but bc of u i have been able to solve the task on the assignment. Thank u.

  • @jahitrst2863
    @jahitrst2863 Před 3 lety +19

    This scared me in the past to start with c++, but it's actually such a simple concept.

  • @eatyourspinachtomperez8700
    @eatyourspinachtomperez8700 Před 7 lety +13

    Thx Paul.
    I recall Jullian Assange saying, "commitment requires sacrifice, courage is contageous". (The latter meaning if you surround yourself w/ your peers, courage is contageous).
    This said, while learning to code, (we're ALWAYS students however), we forget previous lessons etc, the "commitment" part is, constantly reviewing what we may forget.
    This said, THANK YOU for your great work here on CZcams.
    Cheers
    T

  • @edwardmacnab354
    @edwardmacnab354 Před 2 lety

    This is the clearest explanation I have ever seen on this particular item !

  • @johncusack4730
    @johncusack4730 Před 2 lety

    Man, you are amazing! You really know what you're doing. Please, don't stop!!!

  • @mistakenmeme
    @mistakenmeme Před 3 lety +10

    I remember being so intimidated by this when I started learning C++. But then I learned that I didn't need it at all and I forgot about it completely.

    • @ibrahimozmen9668
      @ibrahimozmen9668 Před 2 lety

      so do i have to learn this or what bro i am a cs student who are a completely beginner :)

    • @mistakenmeme
      @mistakenmeme Před 2 lety

      @@ibrahimozmen9668 unless you are building commandline applications for Linux or old terminal based systems, you don't need to worry about it.

    • @ibrahimozmen9668
      @ibrahimozmen9668 Před 2 lety

      @@mistakenmeme thanks bro. I just wanted to learn how it works

  • @morenoramalhofreitas5688
    @morenoramalhofreitas5688 Před 8 měsíci

    Awesome video! I'm brazilian and I want you to know that your video are healping people from all around the world! Thank you very much!

  • @AZUBUIKETHANKGOD-wp2ri
    @AZUBUIKETHANKGOD-wp2ri Před rokem +1

    Quite a lucid explanation. Thanks Paul for making such an awesome video. You've gained a subscriber.

  • @jesusnoseke4038
    @jesusnoseke4038 Před 4 lety

    I have been searching so much for this, even my book doesn't explain what is this, thx a lot

  • @juliedurbin4465
    @juliedurbin4465 Před 6 lety

    This video was so helpful with understanding my embedded systems homework. Your video really clears some things up. Thanks so much!

  • @MaTTeO29c
    @MaTTeO29c Před 4 lety +1

    Thank you for your video! I'm French and it's super easy for me to understand everything. You took your time to be understandable and thank you so much for that!

  • @VietCong467
    @VietCong467 Před 6 lety

    Brilliant explanation, Paul! You just got yourself a new subscriber!

  • @johnnywonglw2351
    @johnnywonglw2351 Před 6 lety +1

    SO WELL-EXPLAIN that I just signed in to give you a thumb-up!!! Thank you for the clear explanation.

  • @makunenbrawl7995
    @makunenbrawl7995 Před 3 lety +1

    That's very simple by listening you. Love the away you explain think. Nice work

  • @puertea2537
    @puertea2537 Před 7 lety +7

    Oh my god you are my hero!!! thank you so much bro... subscribed already

  • @jalalbounaim
    @jalalbounaim Před 2 lety

    Very clear, concise, to the point, intelligible. Many thxs

  • @TheDavidlloydjones
    @TheDavidlloydjones Před 5 lety

    Paul, A nice clear intelligent presentation.
    Well done and thank you!
    (Props also to Hassanin Ahmed, below.)

  • @kebsem
    @kebsem Před 8 lety

    Thank you very much. The video was clear, easy to understand, and helpful!

  • @frostypawsgaming1338
    @frostypawsgaming1338 Před 7 lety

    Cool, this confirmed my book seemed weird that it said this had to double check. good job.

  • @cinarioan2766
    @cinarioan2766 Před 4 lety

    so clear and excellent explanation.
    Just to mention that the arguments must have a space or TAB between them and not a ; or ,

  • @yann8442
    @yann8442 Před 4 lety +3

    You are better at explaining than my actual teachers. +1 sub

  • @s.spambot9095
    @s.spambot9095 Před 2 lety

    OMFG I was reading about this for like 1 hours and couldn't understand shit, and you made it so clear!!! Thank you!!

  • @hoanghieu6389
    @hoanghieu6389 Před 8 lety +32

    excellent explain.

  • @LapCreativeStudio
    @LapCreativeStudio Před 2 lety

    always provide notes to things you have spoken makes us understand better okay 👍
    thank u so much for your efforts
    love from india

  • @shadyfixtech4763
    @shadyfixtech4763 Před rokem

    Well explained Paul. Thanks.

  • @faithabike664
    @faithabike664 Před rokem

    Thanks Paul for this insightful video 😊.

  • @tinal3991
    @tinal3991 Před rokem

    Explicitly explained! Thank you paul!

  • @Kader_1
    @Kader_1 Před rokem

    Thank you, very clear and concise explanation.

  • @adam3416
    @adam3416 Před 6 lety

    finally the first helpful vid on this topic!

  • @sidharths9416
    @sidharths9416 Před 5 lety

    No words to explain. !!! Thanks a lot!!!!!

  • @jm52SD
    @jm52SD Před 6 lety +1

    EXCELLENT video, just subscribed. thanks

  • @celestinemachuca2339
    @celestinemachuca2339 Před 3 lety +1

    thanks, i sleep thru my last lecture, this clears a lot!

  • @Slausonkidd
    @Slausonkidd Před 9 měsíci

    You just got a new subscriber thanks Paul

  • @tuananh284220
    @tuananh284220 Před 3 lety

    I learn something today! Good explanation. Thanks!

  • @anonimosilva6723
    @anonimosilva6723 Před 8 měsíci

    Thank you for this excential explanation!!

  • @leedavis7143
    @leedavis7143 Před 7 lety +2

    perfect lecture!~thank you, Paul~~~~~

  • @RCBajafreak
    @RCBajafreak Před 9 lety

    Perfectly explained, thx a lot bro!

  • @Elliandr
    @Elliandr Před 6 lety

    You explained this way better than my teacher.

  • @mixagames5425
    @mixagames5425 Před 3 lety

    Thanks, this has confused me and I have it on my exam. You cleared it up :)

  • @simonfoo96
    @simonfoo96 Před 3 lety

    Thanks for this tutorial!!! It helps a lot!

  • @default-126
    @default-126 Před 5 lety

    You are just amazing bro, thank you so much, you helped me a lot!

  • @adamodimattia
    @adamodimattia Před 4 lety +2

    Mindblowing! First I wondered what it was in Java, then in C# and now I finally got the answer in C++ :)

    • @frogsam4228
      @frogsam4228 Před 2 lety

      it's actually C

    • @adamodimattia
      @adamodimattia Před 2 lety

      @@frogsam4228 it's identical in this case

    • @frogsam4228
      @frogsam4228 Před 2 lety

      @@adamodimattia Idk tbh bcz I know nothing about c++
      but I'm sure that the format of main itself is different also the standard library is iostream right?
      so I guess they can't be identical right

    • @adamodimattia
      @adamodimattia Před 2 lety +1

      @@frogsam4228 it is, but also in C++ you can use everyting what is in C, all the C libs too

    • @frogsam4228
      @frogsam4228 Před 2 lety

      @@adamodimattia ooh I didn't know that
      thanks a lot

  • @qwerasdfhjkio
    @qwerasdfhjkio Před 5 lety

    Did you make a C programming tutorial? You explanations are so clear

  • @cruisetvshow
    @cruisetvshow Před rokem

    good explanation. well understood. thanks man

  • @shashamnk2525
    @shashamnk2525 Před 9 lety

    This is great! thanks from India paul

  • @dav8485
    @dav8485 Před 5 lety

    Great explanation, Thank you so much!

  • @samdavepollard
    @samdavepollard Před 3 lety

    good one
    i can put scanf back on the shelf and just pass values in when i run stuff
    many thanks for sharing your knowledge
    subbed

  • @BittiKit
    @BittiKit Před 6 lety

    Thank you so much! Very clear explanation.

  • @chikir9777
    @chikir9777 Před rokem

    Thanks works fine. Greetings from Italy

  • @godsugodsu4719
    @godsugodsu4719 Před 3 lety

    Bro holy shit. I misunderstood arg c and argv when i first heard it. But god damn now i finally know how to use it. Thank you so much

  • @hindloumari9884
    @hindloumari9884 Před 5 lety

    Thank you so much for this video ! it really helped me !

  • @meminhofuny
    @meminhofuny Před 11 měsíci

    Thanks for the explanation, God bless you!!!

  • @6183134
    @6183134 Před 9 lety

    (In C programming it is not necessary to put in a for loop the type of the value...) Very good tutorial!!

  • @Moonz97
    @Moonz97 Před 9 lety +3

    Really helpful, thanks!

  •  Před 3 lety

    Great explanation, most of the university professors can't explain this.

  • @RyanLasek
    @RyanLasek Před 3 lety

    Thank you. Your teaching had a very clear progression from basic code to more complex code.

  • @facebook219
    @facebook219 Před rokem

    thanks a lot!!! so nice reverb

  • @alehunter15
    @alehunter15 Před 5 lety

    excellent examples and explanations cheers!

  • @TurskoVideos
    @TurskoVideos Před 7 lety

    Wow makes so much sense now. Thank you!

  • @tassneemaltaf2001
    @tassneemaltaf2001 Před 5 měsíci

    Thank you so much for the help!

  • @ouadieelouardy1171
    @ouadieelouardy1171 Před 10 měsíci

    From ALX AFRICA
    Nice Explanation!

  • @mahfuzuddin4545
    @mahfuzuddin4545 Před 4 lety

    great explanation!

  • @TheMrMalony
    @TheMrMalony Před 7 lety

    This was very helpful, thanks!

  • @richardifeanyicaleb9653

    Bro, thanks for details explanation.

  • @raiyan22
    @raiyan22 Před 3 lety

    Thank you very much! This is well explained! :)

  • @frankkkmate4267
    @frankkkmate4267 Před 3 lety

    Thanks so much dude,it really helps me in terms of my final...

  • @andrasimion6731
    @andrasimion6731 Před 5 lety

    best video explaining this! thank you

  • @louisdasselaar7806
    @louisdasselaar7806 Před 2 lety

    Very good explenation!

  • @wulfriclee1983
    @wulfriclee1983 Před 5 lety

    Great explanation, thanks.

  • @yevgeniysimonov5906
    @yevgeniysimonov5906 Před 4 lety

    Great, thanks for the explanation!

  • @SkySentry7
    @SkySentry7 Před 2 lety +1

    BRAVO! Thanks so much sir.

  • @volkerking5932
    @volkerking5932 Před 3 lety +1

    I'm new in porgramming and this video show me for what is this argc and argv. But for what need argc to count his own call from the elter process?

  • @TheRealHeroDude
    @TheRealHeroDude Před 6 lety

    Thank you this helped me a lot!

  • @bluegiant13
    @bluegiant13 Před 5 lety +1

    Thanks for the explanation I get it, but why is it required? What happens in the background process?

  • @praveen1160
    @praveen1160 Před 5 lety

    great explanation
    understood in one go...

  • @mattm32
    @mattm32 Před 3 lety

    Thanks it is very well explained

  • @youzhen11
    @youzhen11 Před 6 lety

    fantastic explanation!

  • @0xkey434
    @0xkey434 Před 6 lety

    Great tutorial!

  • @RajatAggarwal-rl1fz
    @RajatAggarwal-rl1fz Před 4 měsíci

    This was awesome!

  • @abbassajjadian698
    @abbassajjadian698 Před 7 lety

    Wonderful explanation! Thanks.

    • @mrenmajozi2617
      @mrenmajozi2617 Před 6 lety

      I have only seen
      The way I understand it
      - int main(int argc, char* argv[]) is like saying
      data_type array_name[]
      -int main(int argc, char* argv)
      This one takes a string called argv instead of an array. Since string is declared as char* string
      - int main( int argc, char **argv) uses a pointer concept
      Check this www.programiz.com/c-programming/c-pointers

  • @adetolasanni007
    @adetolasanni007 Před rokem

    Thank you. Pretty decent explanation.

  • @agdimitrova
    @agdimitrova Před 2 lety

    Real savior!!!! Thank you!!!!

  • @GodOfLemon
    @GodOfLemon Před 7 lety +11

    My friend, in C you can declare "int i=0" in the for loop. Wish you the best!

    • @ledues3336
      @ledues3336 Před 7 lety +2

      Alexandru Dinu yes, but that variable would be deleted as soon as the for loop finishes!

    • @upcom1ng116
      @upcom1ng116 Před 3 lety

      @@ledues3336 Can you please explain a bit more? or point to the right source? Because CS50 does the same as Alexandru mention above.

    • @marcelbarbosa281
      @marcelbarbosa281 Před 3 lety +1

      ​@@ledues3336 Yes, this is the intent.

  • @piotrwolak8489
    @piotrwolak8489 Před 6 lety +6

    really helpful, although the if loop seems unnecessary. If the argc

  • @menachemlevi
    @menachemlevi Před 3 měsíci

    great explanation

  • @aurianevez2624
    @aurianevez2624 Před 4 lety

    Thanks super clear explanation !

  • @maormoyal10
    @maormoyal10 Před 5 lety

    Great explanation, thx!

  • @7Mango033
    @7Mango033 Před 8 lety

    very very good video helped a lot thanks dude :)

  • @deepakkumars8139
    @deepakkumars8139 Před 3 lety

    Well and clear explanationn...

  • @Hasansaid51
    @Hasansaid51 Před 5 lety

    how would you do this with displaying different image files? like if i want a dog picture, then when i run the code again i want a mountain image from the command prompt

  • @godsrighteousness5003
    @godsrighteousness5003 Před 4 lety +7

    i always declare variables in for loops in c

  • @user-hh9xc8ut3d
    @user-hh9xc8ut3d Před 4 měsíci

    So clear and simple ❤

  • @canerdogan9916
    @canerdogan9916 Před 3 lety

    perfect video which helped me a lot

  • @washingtonlgois
    @washingtonlgois Před 3 lety

    Subscribed! Thank you! :D