wstringstream和wcout的真正用法

xiaoxiao2021-02-28  68

// ffffffff.cpp : Defines the entry point for the console application. // #include "StdAfx.h" #include "IO.H" #include <iostream> #include <sstream> #include <stdio.h> #include <locale> using namespace std; wstringstream *pBuffer=new wstringstream(); bool MyWrite(std::wstring& s) { pBuffer->clear(); if((*pBuffer)<<s<<std::endl)return true; return false; } bool MyRead(std::wstring& s) { if(NULL!=pBuffer) { pBuffer->clear(); if((*pBuffer)>>s) return true; } return false; } int main(int argc, char* argv[]) { locale loc("chs"); pBuffer->imbue(loc); wchar_t ws1[]=L"ddddddddddd"; wstring ws=wstring(ws1); MyWrite(ws); std::wstring s2; MyRead(s2); std::wcout<<s2; return 0; }

 

转载请注明原文地址: https://www.6miu.com/read-73752.html

最新回复(0)