std::string
을 ASCII 16 진수 출력으로 변환하는 코드가 있습니다. 코드는 정상적으로 실행되지만 작은 문제가 하나 있습니다. 공간을 16 진수로 변환하지 않습니다. 어떻게하면 그 문제를 해결할 수 있을까요?문자열을 ASCII로 변환 C++
#include <iostream>
#include <string>
#include <sstream>
int main(){
std::string text = "This is some text 123...";`
std::istringstream sin(text);
std::ostringstream sout;
char temp;
while(sin>>temp){
sout<<"x"<<std::hex<<(int)temp;
}
std::string output = sout.str();
std::cout<<output<<std::endl;
return 0;
}
'연산자 >>'는 공백을 건너 뜁니다. '연산자 >>'를 사용하지 마십시오. –
['std :: noskipws'] (http://en.cppreference.com/w/cpp/io/manip/skipws) –