Description

Can you explain me and describe me whats that code doing? Especially that first and last line, not that one(I dont know what is that number 10, why is there). Thanks.
1
2
3
4
int main(int argc, char** argv)
{
char odp1,odp2,rozhodnutie;
char name[10];
First line declares three char variables named odp1, opd2 and rozhodnutie.
http://www.cplusplus.com/doc/tutorial/variables/

The second line declares an array of 10 characters, named name.
http://www.cplusplus.com/doc/tutorial/arrays/
Last edited on
Thank you very much, I understood about that number 10, but by first line I meant int main.. I am not sure why there are that agrc, char++ and agrv in brackets..is this needed?
Have you tried websearch with "int main(int argc, char** argv)"?
Yeah but I didn't quite understand that "expert" definition..I need something for
layman. And if it's or isn't needed for my program. Thanks.
It's used for reading command line arguments that are being passed to your program.

argc is the number of arguments.

argv gives you access to the list of arguments.

./yourprogram arg1 arg2

If you run your program like this argc will have the value 3. argv[0] will contain the name used to invoke the program "./yourprogram". argv[1] contains the second argument "arg1", and argv[2] contains the third argument "arg2".
Topic archived. No new replies allowed.