command line aregumente | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

command line aregumente

hi guys, for argv I saw it once declared as int main(int argc, char** argv) and once int main(int argc, char *argv[ ]) how could that be ?once as Pointer of Pointer and once Pointer to array ? any why its declared as char while it takes string values ?

8th Jul 2020, 6:32 AM
Sumer Fattoum
Sumer Fattoum - avatar
3 Answers
+ 1
** works very similar to *[] as an [] is just a pointer to the beginning if the array..... moreover char[] ord char* is the equivalent of a string, as it is a row of letters-> word
8th Jul 2020, 6:51 AM
Alexander Thiem
Alexander Thiem - avatar
+ 1
char* example is a pointer to an character. so example store the adress of one character. If you know that this adress is the start of a string you can just access the string: For example: character adress q 738 e 739 g 740 r 741 If the stored string is „eg“ than char* example points on e and store therefore the adress 739, but you can still acces g as you just have to increase a by one (as g is stored at 740)
8th Jul 2020, 10:07 AM
Alexander Thiem
Alexander Thiem - avatar
0
aha..ok nice ..thnx..but a string is an array of chars together...but here every Element is declared as char but you can put string in every Element instead of that char
8th Jul 2020, 9:36 AM
Sumer Fattoum
Sumer Fattoum - avatar