Traditional Culture Encyclopedia - Photography and portraiture - Hangzhou Emma wedding photography

Hangzhou Emma wedding photography

In C++ code, add an impossible number at the end of the array, such as-1, and then read it in C#:

C++ code:

char *A(char buf[])

{

char buffer[50]= { };

int I = 0;

while(buf[i]! = '/0 ' & amp; & amp & lt49) {

buff[I]= buf[I]

i++;

}

buffer[I]=- 1;

Return buffer;

}

/////////////////////////////

C# code:

Unsafe {

char * buffer = A(buf);

int I = 0;

while(buffer[i++]! = - 1) {

console . out . writeln(buffer[I]);

}

}

Or you can write another function int getSize () in the DLL to return the length of the array:

C++ code:

Static int size = 0;;

int getSize(){

Returns the size;

}

char *A(char buf[])

{

char buffer[50]= { };

while(buf[i]! = '/0 ' & amp; & amp & lt49) {

buff[I]= buf[I]

size++;

}

Return buffer;

}

C# code:

C# code:

Unsafe {

char * buffer = A(buf);

int size = getSize();

for(int I = 0; I< size; i++) {

console . out . writeln(buffer[I]);

}

}