I have just started using Visual Studio 2012, which I wish to use to write C++ code.
To get to know how the IDE works I have created a very simple 'add two numbers' program.
#include<iostream>
#include<cstdlib>
int add(int a , int b)
{
return a+b;
}
int main(int argc, char** argv)
{
int a = atoi(argv[1]);
int b = atoi(argv[2]);
std::cout << "The sum of the arguments is " << add(a,b) << std::endl;
return 0;
}
If I hard-code the values of 'a' and 'b' (ie no argv's require to be passed), then using F7 to compile and Ctrl F5 to run the executable makes the program run perfectly.
But how do I pass the argv
's to the program if I want to specify them at run time?
According to the 2nd answer on this SO thread I have to use Project Tab-> Properties-> Configuration Properties-> Debugging and then enter in the Right Hand Side under (Command Arguments),
But this seems very inconvenient if I want to make several quick runs of the program and test out the executable for different 'argv's.
You can try CLI Args Made Easy from http://n0n4m3.codingcorner.net/?p=214. There are versions for VS2010 and VS2012.