문제

From a managed c++ function I want to invoke an unmanaged function that expects a 'const char *' as an argument.

Are a) and b) below correct? For b), do I need to pin_ptr 'hello'? What about a)? Thanks.

a) myFunction( "hello" );

b)

char hello[10] ;
strcpy( hello, "hello" );
myFunction( hello );
도움이 되었습니까?

해결책

Both are fine. You don't need an extra strcpy in b) though, just do:

char hello[] = "hello";
myFunction( hello );

which now becomes pretty much the same as a).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top