Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Link File as an input arguent 1

Status
Not open for further replies.

shaharpan

Programmer
Mar 23, 2005
6
US
Hi! All,

I am running VC++ , my project requires to read a file as an argument and generate a new file as an output argument.

I am able to compile the code from command prompt

C:\project\list.exe test.txt out.txt

here test.txt is the input for the program

and out.txt is the file used for output.

but there is way to configure this link using VC++ menu , properties or setting.

I need to configure these in VC++.

Please let me know the steps .

bcoz when i compile the code from VC++ its gives me

an error : Usage:directory <inputfile> <outputfile>Press any key to continue

THAT MEANS ITS NOT ABLE TO ACCESS THESE FILES

my code

void main(int argc,char *argv[])
{
if (argc !=3)
{
cout << "Usage:directory <inputfile> <outputfile>";
exit(1);
}

fstream readStream(argv[1],ios::in);
fstream writeStream(argv[2],ios::eek:ut);

if (! readStream.is_open() || ! writeStream.is_open()) {
cout << "Cannot open input/ouptut files. Try again!";
exit (1);
}


please tell me how do i run this code from vc++ , gui

and how do i link the input and output files.

thanz in advance.

Regards
Arpan
 
It is different in different versions of VC++

In VC++ 6.0
Go to Project->Settings, then switch to the Debug tab and type in your program arguments into the Program arguments text box (e.g. "test.txt out.txt" without the quotes).

In VC++ 7.1
Go to Project->Properties, Switch to Configuration Properties->Debugging, and type in your program arguments into the Command Arguments text box (e.g. "test.txt out.txt" without the quotes).

In other versions it is probably something similar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top