lordiano
asked on
Visual Studio Help
Hi, I am new to Visual Studio as I have been compiling my code and executing it in unix/linux. This is a very stupid problem i have.. I have no idea how to pass in the command line argument for Main when I execute the program.
For example:
I have a piece of code goes like this
int main(int argc, char* argv[]) {
ifsteam infile;
infile.open(argv[1]);
infile.close();
}
I know how to compile it using Visual Studio .Net, but I dont know how to Execute it with a given argument to the main function.
Say maybe I want the argv[1] to be something like Myfile.txt
How to I pass that Myfile.txt to Visual Studio so that it would recognize it as if i were to type : Myprogram Myfile.txt
thanks a lot
For example:
I have a piece of code goes like this
int main(int argc, char* argv[]) {
ifsteam infile;
infile.open(argv[1]);
infile.close();
}
I know how to compile it using Visual Studio .Net, but I dont know how to Execute it with a given argument to the main function.
Say maybe I want the argv[1] to be something like Myfile.txt
How to I pass that Myfile.txt to Visual Studio so that it would recognize it as if i were to type : Myprogram Myfile.txt
thanks a lot
Project - Settings - Debug. Write Myfile.txt in Program arguments edit box.
ASKER
I am using Visual Studio .NET
Hmm I dont see Project-settings...
Still Can't find that Program Arguments edit box thing...
Hmm I dont see Project-settings...
Still Can't find that Program Arguments edit box thing...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ahh, i see
hmm sorry 1 more question, How do i enter more than 1 command arguments? like myfile.txt and mynewfile.txt as argv[1], and argv[2]. Is it possible to do that?
thanks.. I will raise the point of this question because this is actually a new question.. this will be for AlexFM only.
hmm sorry 1 more question, How do i enter more than 1 command arguments? like myfile.txt and mynewfile.txt as argv[1], and argv[2]. Is it possible to do that?
thanks.. I will raise the point of this question because this is actually a new question.. this will be for AlexFM only.
Write number of arguments in the edit box:
file1.txt file2.txt
In this case argv[1] = "file1.txt", argv[2] = "file2.txt"
file1.txt file2.txt
In this case argv[1] = "file1.txt", argv[2] = "file2.txt"