0

Please can answer my question:

How can I verify that a certain function has two parameters otherwise print an error message. I am talking about c language.

24th Nov 2020, 9:10 PM
Amal Gil
Amal Gil - avatar
3 Antworten
+ 4
The main function gets its arguments from the command line or OS or calling program. Where typically the first argument passed is the program itself. This is how command line programs receive their options etc.
gt; myprog -v Where myprog would be the executable and -v would be the flag argument passed. argc would be equal to 2 argv[0] would be myprog (or path to it) argv[1] would be -v
24th Nov 2020, 9:59 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Then what about the main function. Int main (int argc,char *argv[ ]);
24th Nov 2020, 9:33 PM
Amal Gil
Amal Gil - avatar
0
Your compiler will give you an error, and btw, since you are talking about C, don't forget about 'int main (void)', because main() is not C, empty parameter and void paramater is different in C (it's not in C++). But, as far as I know, () and (void) is the same in C in a certain version (maybe I heard or read wrong, I think it's C99(?)). Edit: argc stands for argument count, and argv stands for argument vector. Hope this helps http://crasseux.com/books/ctutorial/argc-and-argv.html#:~:text=The%20name%20of%20the%20variable,one-dimensional%20array%20of%20strings.
24th Nov 2020, 11:56 PM
LastSecond959
LastSecond959 - avatar