0
我正在使用windows visual studio。我想使用mex在C++中读取.txt文件。下面是小例子:使用mex读取和写入文件
#include <mex.h>
#include <iostream>
#include <fstream>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
ifstream data;
return;
}
当我运行在MATLAB mex test.cpp
,我碰到下面的错误。使用MEX TEST.CPP
错误
G:\ TEST.CPP(35)
:错误C2065:ifstream的:未声明的标识符
G:\ TEST.CPP( 35)
:错误C2146:语法错误:缺少';'前识别符 '数据'
G:\ TEST.CPP(35)
:错误C2065:数据:未声明的标识符
我也会喜欢到输出.txt文件,但是当我尝试ofstream
时发生类似的错误。从我看到的,我认为matlab不认识标题
#include <iostream>
#include <fstream>
我能做些什么来读/写mex文件?除了iostream和fstream之外,还有另外一种在mex中读/写文件的方法吗?