The trouble is that if you can't open it for another reason (permissions, for example) you may think it does not exist but it does. You will probably need to check an error condition to see if the problem is really nonexistence or something else if you want a really robust solution.
On UNIX-like systems you can use the stat() function. If stat() fails, check errno to see if it indicates that the file (or a component of the path) doesn't exist.