Solved

Visual Studio Help

Posted on 2003-11-13
5
371 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 127
convert char array to number in c 5 86
Add values of each row in an array 3 63
Where are the c++ header files to use in Eclipse? 4 23
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

789 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