I'm trying to get the Matlab C/C++ API working in Visual
C++ 2005 Express. Ultimately I will want to be able to
read/write simple .mat files into my standalone C++
So far, I am just attempting to get the basics working,
but keep coming up against access violation errors eg
" Unhandled exception at 0x0001ad06 in basic.exe:
0xC0000005: Access violation reading location 0x0001ad06."
even when I am copy&paste-ing code from examples that
Can anyone point me in the right direction?? Or give me
some foolproof code that is known to work ,that I can try
out. My code to follow.
Many thanks in advance,
using namespace std;
#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmx.lib")
int _tmain(int argc, _TCHAR* argv)
const char *file="C:\\Temp\\myFile.mat";
const char *mode="r";
printf("Reading file %s...\n\n", file);
pmat = matOpen(file, mode); //ERROR occurs here*
// *interestingly although the error only ever occurs when
this line is present, it doesnt matter if this line is
nver reached - ie if we move it to after the return
clause, we still get the same error.