Is there a way to check file existence. I know it tells you how in the tutorials, but that way doesn't work for me.
And I am using Visual C++ .net
Is there a way to check file existence. I know it tells you how in the tutorials, but that way doesn't work for me.
And I am using Visual C++ .net
>>Is there a way to check file existence.
Yes.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Post your code that "doesn't work". Maybe you did something wrong. Anyways, one way to check is to simply open the file in read mode (with no-create), if it works, the file exists, if not, it doesn't
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
#include <io.h>
that is code from the c tutorial at http://www.cprogramming.com/tutorial/lesson14.html which I adapted to be used in my program, which the compiler returned the error of access not being a valid functionCode:if(access(argv[1], 00)) //access returns 0 if the file can be accessed { //under the specified method (00) cout<<"File does not exist"; //because it checks file existence return 0; }
try this .
This checks for errors when opening a file.Code:if (!=infile) // if not equal to name of file (ifstream infile) { cerr << "cant open"; exit (-1); } // then your code follows
C++ Rules!!!!
------------
Microsoft Visual Studio .NET Enterprise