473,322 Members | 1,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

get path

16
hi all i want to get the path of the file that i want to open it in argument of main() function how can i do it?
Apr 22 '11 #1
7 2521
Here is a code, if I'm right:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(int argc, char* argv[]) {
  5.    cout << argv[0];
  6.    return 0;
  7. }
  8.  
Apr 22 '11 #2
saharit
16
thanks Alex but where i put my path of file ? like this c:\document\d.doc to open this file?
Apr 22 '11 #3
Sorry that I misunderstood your question.

So you want to open a file in your program, and you would pass the filename as an argument to your executable, am I right?


You can do it in a command line, or a batch file, or
even with a call from other program. If you want to do
from your program, it's possible too, but a bit "harder" :)

The simple method is from command line:
Expand|Select|Wrap|Line Numbers
  1. yourprogram.exe  "pathname"
  2.  
Apr 24 '11 #4
saharit
16
yes, u right but where is the argument that i use :(?
Apr 24 '11 #5
All arguments of your program in argv.
The argv[0] argument is automatically filled up
with the program's path.
The first argument you passed to your exe in command line
will be in argv[1].
The second one is in argv[2] and etc.
Apr 25 '11 #6
saharit
16
in turbo c++ how can i define aegument in RUN Menu?
Apr 25 '11 #7
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Program Arguments dialog box
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Program Arguments dialog box is where you
type in command-line arguments for your
running programs exactly as if you had typed
them on the DOS command line.


┌─ Arguments ──────────────────────────┐
│ │
└──────────────────────────────────────┘
The Arguments input box is where you enter
the arguments that you want Turbo C++ to pass
to your running program.



It's from Turbo c++ Run->arguments->help
Apr 26 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
9
by: Bengt dePaulis | last post by:
I have a local directory that I want to include in my sys.path How to save it permanently? Regards /Bengt
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
4
by: python | last post by:
Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) On...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
6
by: bukzor | last post by:
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.