C + + output CString encountered a wonderful problem

Source: Internet
Author: User

First on the code

1 //WebConteng.cpp:Defines the entry point for the console application.2 //3 4#include"stdafx.h"5#include <stdlib.h>6#include <afxinet.h>7#include <iostream>8#include <fstream>9 using namespacestd;Ten  One intMainintargcChar*argv[]) A { -printf"Hello world!\n"); -     ///////////////////////////////////////////// theCInternetSession session ("HttpClient");  -     Char* URL ="http://www.baidu.com";  -CHttpFile *pfile = (CHttpFile *) session.     OpenURL (URL);  -      + DWORD Dwstatuscode;  -Pfile->QueryInfoStatusCode (Dwstatuscode);  +     if(Dwstatuscode = =HTTP_STATUS_OK) A     {      at CString content;  - CString data;  - ofstream o_file; -O_file.open ("11.txt"); -          while(pfile->ReadString (data)) -         {      inContent + = data +"\ r \ n";  -             Char* test=data. GetBuffer (data. GetLength ()); toO_file << Test <<Endl; +         } - o_file.close (); the content.     TrimRight ();  *printf"%s\n", content);  $     }      Panax NotoginsengPfile->Close ();  -     Deletepfile;  the session.  Close ();  +     //////////////////////////////////////////////////////// ASystem"Pause"); the     return 0; +}
View Code

If the data is not assigned to test, but the direct output data will be a very wonderful problem, the output is all eight-bit numbers

As long as the data into the char* is OK;

Pit dead me for one hours ...

C + + output CString encountered a wonderful problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.