여기서 무엇이 잘못 되었는가에 대해서는 잘 모른다.C++ stringstream에서 const char * 검색
std::stringstream ss("Title");
ss << " (" << 100 << ")";
const char* window_title = &ss.str().c_str();
나는 make
으로 달렸습니다. 행복하지 않았습니다.
stringstream
를 만들고있어에서 "(100)"그것에
[17%] Building CXX object CMakeFiles/game.dir/src/main.cpp.o
path: error: cannot take the address of an rvalue of type 'const value_type *'
(aka 'const char *')
const char* window_title = &ss.str().c_str();
^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/game.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/game.dir/all] Error 2
make: *** [all] Error 2
. 그런 다음 char
이고 그 포인터를 window_title
에 저장하는 "C 문자열"을 검색하고 있습니다.
무엇이 잘못 되었나요?
스팸 태그를 사용하지 마십시오! C는 C++이 아닙니다! – Olaf
주소'ss.str()을 취할 필요가 없습니다 .c_str();은 이미'const char *'를 반환합니다. –
어, 왜 내가 10K 다운 보턴을 얻었습니까? 나는 그 문제를 설명했다. 그렇지 않습니까? – Lolums