Click here to Skip to main content
15,894,410 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CListCtrl Problem Pin
Naveen28-Sep-08 19:01
Naveen28-Sep-08 19:01 
QuestionWrite a buffer to stringstream Pin
CodingLover28-Sep-08 18:43
CodingLover28-Sep-08 18:43 
AnswerRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:04
Naveen28-Sep-08 19:04 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:08
CodingLover28-Sep-08 19:08 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:26
Naveen28-Sep-08 19:26 
NewsRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:35
CodingLover28-Sep-08 19:35 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:54
Naveen28-Sep-08 19:54 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 20:18
CodingLover28-Sep-08 20:18 
I try what you suggest. But no luck.

My xml stream like this, <state>0</state> but the buffer only contain < in my previous code. With your suggestion, nothing is contain. Frown | :(

Here is my full code.
int GetStat::CopyTo(ostream& str)
{
	HRESULT hrSeek, hrRead;
	ULONG readLen = 0;
	LARGE_INTEGER startPos = {0};

	// Seek to the begining of the stream
	if((hrSeek = pOutFileStream->Seek(startPos, STREAM_SEEK_SET, NULL)) != S_OK)
	{
		LOG4CPLUS_ERROR(RF_GROUP_LOGGER, "Stream seek failed." << __FUNCTION__);
		return -1;
	}

	do
	{
		char writeBuffer[256] = {0};
		wchar_t ReadBuffer[100] = {0};
		hrRead = pOutFileStream->Read(writeBuffer, sizeof(writeBuffer), &readLen);
		//int rec = WideCharToMultiByte(CP_ACP, NULL, ReadBuffer, -1,writeBuffer, 100, NULL, NULL);
		//if(rec == 0)
		//	std::cout << "WideCharToMultiByte" << std::endl;
		str.write(writeBuffer, readLen);
	}while(hrRead == S_OK);

	return 0;
}

std::string GetStat::GetAsString(void)
{
	stringstream str(ios::in|ios::out|ios::binary);

	if(CopyTo(str) == 0)
		return str.str();

	return "";
}

int GetStat::Result()
{
	std::string temp = GetAsString();
	std::cout << temp << std::endl;

	char buff[256] = {0}; 
	sprintf(buff, "%s", temp.c_str());
}


You can find the buff in above code. In Result() method you can see I've print the output to the console. It gives the correct xml stream. But buff contain only the first character.

I appreciate your help all the time...
CodingLover Smile | :)

GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 20:29
Naveen28-Sep-08 20:29 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 20:36
CodingLover28-Sep-08 20:36 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 21:25
Naveen28-Sep-08 21:25 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 22:44
CodingLover28-Sep-08 22:44 
AnswerRe: Write a buffer to stringstream Pin
followait28-Sep-08 19:18
followait28-Sep-08 19:18 
NewsRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:26
CodingLover28-Sep-08 19:26 
QuestionHow do I find the variable causing the memory leak ? Pin
SherTeks28-Sep-08 18:25
SherTeks28-Sep-08 18:25 
AnswerRe: How do I find the variable causing the memory leak ? Pin
Naveen28-Sep-08 18:59
Naveen28-Sep-08 18:59 
QuestionA sliding container may be Pin
methhoo28-Sep-08 14:45
methhoo28-Sep-08 14:45 
AnswerRe: A sliding container may be Pin
Sarath C28-Sep-08 17:58
Sarath C28-Sep-08 17:58 
GeneralRe: A sliding container may be Pin
santhoshv8428-Sep-08 20:41
santhoshv8428-Sep-08 20:41 
Questioncompiler problem Pin
paullmcnally28-Sep-08 8:28
paullmcnally28-Sep-08 8:28 
AnswerRe: compiler problem Pin
CPallini28-Sep-08 9:49
mveCPallini28-Sep-08 9:49 
QuestionMemory leak when using a dll Pin
Ali Tavakol28-Sep-08 4:40
Ali Tavakol28-Sep-08 4:40 
QuestionRe: Memory leak when using a dll Pin
Mark Salsbery28-Sep-08 9:34
Mark Salsbery28-Sep-08 9:34 
AnswerRe: Memory leak when using a dll Pin
Joe Woodbury28-Sep-08 18:01
professionalJoe Woodbury28-Sep-08 18:01 
GeneralRe: Memory leak when using a dll Pin
Ali Tavakol28-Sep-08 19:37
Ali Tavakol28-Sep-08 19:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.