cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
File name extracting
File name extracting
Jan 5, 2011 at 9:53am UTC
saicam
(8)
How can I extract a file name and save it on a string?.
Jan 5, 2011 at 9:56am UTC
wolfgang
(381)
Where are you extracting it from? Do you want a user to enter a file's name? Do you want the program to search for a file? Or do you want the name of the program and its location when the program is run?
Jan 5, 2011 at 10:01am UTC
saicam
(8)
yes,i want a user to enter a file name and tell if the file is located or not.
Jan 5, 2011 at 10:06am UTC
wolfgang
(381)
Use the string and fstream libraries. Read in a string, then try to open the file with fstream. Then run checks to see if it was successful or not.
Reference:
http://www.cplusplus.com/reference/iostream/fstream/
http://www.cplusplus.com/reference/string/
Jan 5, 2011 at 10:12am UTC
saicam
(8)
i already used it but i can't determine if the file is located or not..
Jan 5, 2011 at 10:25am UTC
kbw
(9488)
A better way is to use stat() as that accesses the file's metadata and doesn't touch the file.
Topic archived. No new replies allowed.