File Exist Command Line

i just want to know, is there a command line in C++ language (i know, "command line") that can check that if a file exist and if it does, it will do "something" and if it doesn't exist, it will do "something else". This is really similar to the "IF EXIST" command on Batch. All help will be appreciated.

-chaos1271
Last edited on
If this is a question for Windows programming, I can say: Use the Windows API function calls FindFirstFile(), or maybe OpenFile() wth the OF_EXIST flag.

If this is Mac or Linux, I don't know. I also don't know of any C/C++ method as I rarely do file handling with the STL or even good old C.
access(filename, F_OK); //unistd.h

If you are going to open it, you may try open it.
Topic archived. No new replies allowed.