cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How to check if a file exist in a direct
How to check if a file exist in a directory
Jun 18, 2012 at 4:34pm UTC
nhim175
(10)
Hi, I've got a problem.
User enter a file name, how to check if the file exist or not?
Thanks!
Jun 18, 2012 at 4:40pm UTC
georgewashere
(244)
1
2
3
4
5
ifstream my_file(
"test.txt"
);
if
(my_file.good()) {
// read away
}
from stackoverflow.net
http://www.cplusplus.com/reference/iostream/ifstream/
Last edited on
Jun 18, 2012 at 4:41pm UTC
Jun 19, 2012 at 7:36am UTC
nhim175
(10)
I used fopen :) I think it's the easiest way. anw, thanks!
Topic archived. No new replies allowed.