Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 5th, 2004, 09:33 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default Retrieve data

Hello,

I'm quite new to C++, and am using it in the command line.

My problem is, to call an .exe file with a parameter you would do this:

c:\>program.exe file.txt

to pass a text file to it.

Is it possible for a C++ application to retrieve the data in that parameter?

Thanks and sorry if this is a simple question.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
__________________
-Snib - http://www.snibworks.com
Where will you be in 100 years?
Reply With Quote
  #2 (permalink)  
Old November 6th, 2004, 03:12 AM
Authorized User
 
Join Date: Dec 2003
Location: Bristol, , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default



yes, you can pick up the parameters thus:

int
main(int argc, char *argv[])
{

// argc will tell you how many arguments were on the command line
// *argv is an array of pointers to those arguments.

}

argv[0] points to the name of the program so

C:\>Myprog.exe one two three

argc = 3
argv[0] = "Myprog.exe"
argv[1] = "one"
argv[2] = "two"
argv[3] = "three"

OK ?



Georges
Reply With Quote
  #3 (permalink)  
Old November 6th, 2004, 11:09 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks very very much, will try this when I can!!

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote




Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve data dynamically pitiporn Classic ASP Basics 3 May 28th, 2006 11:21 PM
cannot retrieve data because of redirecting artuc General .NET 0 December 18th, 2004 02:52 AM
trying to retrieve data from another page Calibus Classic ASP Databases 3 July 17th, 2004 11:51 PM
data retrieve from three tables mateenmohd SQL Server 2000 2 October 7th, 2003 04:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.