F
fdm
In a function I call fopen:
template<class V, class Dt>
unsigned int LoadFile(std::string & path) {
std::cout << "path = " << path << std::endl;
FILE *fptr = fopen(path.c_str(), "rb");
if (fptr==NULL) {
std::cout << "file not found!" << path << std::endl;
}
...
...
}
When I run it I get this:
path = /home/fdm/test.h2
file not found!
fptr is NULL, meaning that it cannot find the file. I have double checked
that the file exist in this location.
Now here comes the wierd part. If I manually set the SAME path in the
function like:
template<class V, class Dt>
unsigned int LoadFile(std::string & path) {
std::cout << "before = " << path << std::endl;
path = "/home/fdm/test.h2";
std::cout << "after = " << path << std::endl;
FILE *fptr = fopen(path.c_str(), "rb");
if (fptr==NULL) {
std::cout << "file not found!" << path << std::endl;
}
...
...
}
I get this:
before = /home/fdm/test.h2
after = /home/fdm/test.h2
and fptr is not NULL (the file is read successfully). But as can be seen
from the printed messages there is no difference between 'path' before and
after updating it! So why does it only work when I update 'path' manually in
the function??
I get this error on Ubuntu 9.04. If I run it on windows vista 64 bit in
visual studio it works fine! Any ideas??
template<class V, class Dt>
unsigned int LoadFile(std::string & path) {
std::cout << "path = " << path << std::endl;
FILE *fptr = fopen(path.c_str(), "rb");
if (fptr==NULL) {
std::cout << "file not found!" << path << std::endl;
}
...
...
}
When I run it I get this:
path = /home/fdm/test.h2
file not found!
fptr is NULL, meaning that it cannot find the file. I have double checked
that the file exist in this location.
Now here comes the wierd part. If I manually set the SAME path in the
function like:
template<class V, class Dt>
unsigned int LoadFile(std::string & path) {
std::cout << "before = " << path << std::endl;
path = "/home/fdm/test.h2";
std::cout << "after = " << path << std::endl;
FILE *fptr = fopen(path.c_str(), "rb");
if (fptr==NULL) {
std::cout << "file not found!" << path << std::endl;
}
...
...
}
I get this:
before = /home/fdm/test.h2
after = /home/fdm/test.h2
and fptr is not NULL (the file is read successfully). But as can be seen
from the printed messages there is no difference between 'path' before and
after updating it! So why does it only work when I update 'path' manually in
the function??
I get this error on Ubuntu 9.04. If I run it on windows vista 64 bit in
visual studio it works fine! Any ideas??