0
저는 이것이 C++ Win32 API 유틸리티를 많이 이해하지 못해서 꽤 기본적인 문제가되기를 바라고 있습니다.sprintf() 함수로 문자열을 사용하는 데 문제가 있습니다.
어쨌든 sprintf()
기능에 문제가 있습니다. 나는이 같은 문자열을 사용하여 아무런 문제가 없었다 :
//memory is a void pointer that maps a file to shared memory
sprintf((char *)memory, "Shared memory message"); //Write to shared memory
을하지만 그것은 작동하지 않습니다 string
변수 ....
sprintf((char *)memory, str_var); //Write to shared memory
를 사용하려고 할 때 말한다 오류가 : no suitable conversion function from "std::string" to "const char *" exists
. 나는 심지어 memory
으로했던 것처럼 타입 캐스팅으로 이것을 고칠 수조차 없다.
이것은 꽤 모순 된 것처럼 보입니다. 내가 뭘 잘못하고 있으며, 받아 들일만한 가치를 어떻게 내놓을 수 있습니까? 그래서 예를 들어,
: 당신이 sprintf
필요 IFF
표준 : : 문자열은 const를 숯불 *로 변환은 문자열과 C 스타일 문자열의 차이를 배우려고 –
변환 할 .c_str() 멤버 메소드를 사용 할 수 없습니다. [http://stackoverflow.com/questions/10958437/how-to-convert-an-stdstring-to-c-style-string][1] [1] : http://stackoverflow.com/questions/10958437/how-to-convert-an-stdstring-to-c-style-string – BufBills