Solved

Visual Studio Help

Posted on 2003-11-13
5
368 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:lordiano
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9738943
Project - Settings - Debug. Write Myfile.txt in Program arguments edit box.
0
 

Author Comment

by:lordiano
ID: 9738973
I am using Visual Studio .NET
Hmm I dont see Project-settings...
Still Can't find that Program Arguments edit box thing...
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
ID: 9738979
Sorry, it was for Visual Studio 6. In .NET:

Right-click on the project name in Solution Explorer - select Properties. Select Configuration Properties - Debugging. Fill Command Arguments edit box.
0
 

Author Comment

by:lordiano
ID: 9739003
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.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9739047
Write number of arguments in the edit box:

file1.txt file2.txt

In this case argv[1] = "file1.txt", argv[2] = "file2.txt"
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now