I get an Access violation reading location when using mxCreateCharMatrixFromStrings
이전 댓글 표시
I am using mxCreateCharMatrixFromStrings in a C++ console app. I have read in the 'string' from a .mat file into a char *cData[10] using mxArrayToString(). I can see the string in cData[0] and it is what I expected. I take that variable and then call the following in C++:
mxArray *pMatr = nullptr;
pMatr = mxCreateCharaMatrixFromStrings(345, (const char**)cData[0]); <-- this line is where I get the access violation error!
my goal is to have an pointer to an 1X344 mwArray to pass into a matlab generated library.
I am using MatLab R2014 as the matlab generated library needed to be 32 bit.
Thanks,
채택된 답변
추가 답변 (1개)
Mohan Feng
2018년 12월 11일
0 개 추천
It seems that in your code, cData[0] is of type char*, but you convert it into type char**, which may cause a segmentation fault.
댓글 수: 2
Edwardo Medina
2018년 12월 11일
James Tursa
2018년 12월 12일
I don't believe you. Passing in cData[0] as the 2nd argument couldn't possibly have worked, since that address points to a string of characters and is not the same as cData all by itself.
카테고리
도움말 센터 및 File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!