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