If I ran a C++ program
./program arg1
argv[1] exists, however is there a way to check if argv[2] exists?
Yes, look at the value of argc:
argc
if (argc > 2) { ... use argv[2] ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!