File name extracting

How can I extract a file name and save it on a string?.
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?
yes,i want a user to enter a file name and tell if the file is located or not.
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/
i already used it but i can't determine if the file is located or not..
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.