Hi, I was wondering if someone could explain to me how to run a program in terminal with this format.
MyCode <Text.txt> <AnotherText.txt> <Flag>
The flag should determine what part of the Mycode to run.
Example flag = 1; Run thisFunction() or flag = 2; Should be able to Run thisOtherFunction();
Hope its not to confusing
Thanks
So I tried the example above however the argv[3] is never equal to "1" or "2". when the I type 1 or 2 in the terminal. I tried changing it to argv[3]== '1' but of course that cannot be since its pointer to int comparison. Any Idea How I can make it work?
I actually checked before and the result is correct that argv[3] hold, however the: if(argv[3] == "1"){}
will not execute even though the argv[3] is equal to 1, which is confusing?
I actually checked before and the result is correct that argv[3] hold, however the: if(argv[3] == "1"){}
will not execute even though the argv[3] is equal to 1, which is confusing?
It's not that confusing. The address of "1" was not equal to the address stored in argv[3]. What those addresses pointed to wasn't compared.
When you compared argv[3] to a std::string type, you actually compared the contents so the outcome was as you expected.