Ken H

Ken H

  • NA
  • 646
  • 360.9k

To set the value of a two-dimensional array in c++ dll

Mar 19 2015 6:09 AM
Hello friend,
 The following code will not run properly.
 
C++ codes:
// mytest.cpp
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
extern "C"{
_declspec(dllexport) void _setv(char ***s, int row, int column){
for (int i = 0; i < row;i++){
for (int j = 0; j < column;j++)
{
strcat(s[i][j],"The value in here.");
}
}
}
}
C# codes:
class Program
{
[DllImport("mytest.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void _setv(string[,] s, int row, int column);
static void Main(string[] args)
{
string[,] _arr = new string[2, 2]{{"",""},{"",""}};
_setv(_arr, 2, 2);
}
}
 
Thank. 
 

Answers (4)