Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this asterisk for?

Tags:

c

I'm learning c programming, and I don't understand what is this asterisk for in the main method.

int main(int argc, char* argv[])

like image 344
Strawberry Avatar asked Dec 07 '25 06:12

Strawberry


1 Answers

char* a; means that a is a pointer to variable of type char.

In your case argv is a pointer to a pointer (or even several of them - it is specified in argv in your case) to a variable(s) of type char. In other words, it's a pointer to an array (of length argv) of pointers to char variables.

You can even write your code this way: int main(int argc, char** argv) and nothing, actually, changes as soon as char* a is the same as char a[].

like image 127
asciz Avatar answered Dec 10 '25 01:12

asciz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!