print_string:
lodsb ; grab a byte from SI
cmp al, 0
;or al, al ; logical or AL by itself
jz .done ; if the result is zero, get out
mov ah, 0x0E
int 0x10h
Run Code Online (Sandbox Code Playgroud)
我想知道它是如何or al, al工作的.我知道它会测试是否已经打印出字符串中的所有字符?但我不明白逻辑.
我想解释一下这个函数的一部分是做什么的:
bool Compare(CBox* pBox) const
{
if (!pBox)
return 0;
return this->Volume() > pBox->Volume();
}
Run Code Online (Sandbox Code Playgroud)
如果(!pBox)检查怎么办?如果声明必要吗?
我想知道如何在不使用LibCurl的情况下将网站的HTML源代码下载到字符串中.我在网上搜索了使用Wininet的例子.
下面是我用于Wininet的示例代码.我如何使用Winsock做同样的事情?
#include "stdafx.h"
#include <windows.h>
#include <wininet.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#pragma comment ( lib, "Wininet.lib" )
int main()
{
HINTERNET hInternet = InternetOpenA("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET hConnection = InternetConnectA(hInternet, "google.com", 80, " ", " ", INTERNET_SERVICE_HTTP, 0, 0);
HINTERNET hData = HttpOpenRequestA(hConnection, "GET", "/", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
char buf[2048];
string lol;
HttpSendRequestA(hData, NULL, 0, NULL, 0);
DWORD bytesRead = 0;
DWORD totalBytesRead = 0;
// http://msdn.microsoft.com/en-us/library/aa385103(VS.85).aspx
// …Run Code Online (Sandbox Code Playgroud) 我将如何编写一个函数来等待 POST 完成?我正在登录一个有多个重定向的网站,并使用 connect()QNetworkReply()导致无限的 GET 请求。
我现在正在使用等待计时器:
test->sendPostRequest(url, loginData);
QEventLoop loop;
QTimer::singleShot(8000, &loop, SLOT(quit()));
loop.exec();
test->sendGetRequest(request);
Run Code Online (Sandbox Code Playgroud) 为什么会导致分段错误?
#include <iostream>
#include <functional>
using namespace std;
int main() {
function<int(int,int)> hcf = [=](int m, int n)mutable->int{
// cout << "m: " << m << " n: " << n << endl;
if(m<n) return hcf(n,m);
int remainder(m%n);
if(0 == remainder) return n;
return hcf(n,remainder);
};
cout << hcf(10,15) << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我添加了mutable关键字.不应该按值传递工作吗?为什么这需要传递引用?是因为我hcf递归地打电话?
有什么区别:
//Example of "Complicated Array Declarations" from C++ Primer
int arr[10] = {1,2,3,4,5,6,7,8,9,10};
int (*Parr)[10] = &arr;
Run Code Online (Sandbox Code Playgroud)
和:
int arr[10] = {1,2,3,4,5,6,7,8,9,10};
int *Parr = arr;
Run Code Online (Sandbox Code Playgroud)
两者都是指向整数数组的指针.但是为了访问第arr一个片段中的第一个元素,我必须这样做,**Parr而在第二个元素中,我只需要取消引用一次*Parr