wstringstream和wcout的真正用法

来源:互联网 发布:spark php客户端 编辑:程序博客网 时间:2024/06/05 05:44
// 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;}

 

原创粉丝点击