小编Qua*_*ale的帖子

或者al,汇编语言

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工作的.我知道它会测试是否已经打印出字符串中的所有字符?但我不明白逻辑.

assembly

2
推荐指数
1
解决办法
2114
查看次数

通过指针比较

我想解释一下这个函数的一部分是做什么的:

bool Compare(CBox* pBox) const
    {
        if (!pBox)
            return 0;
        return this->Volume() > pBox->Volume();
    }
Run Code Online (Sandbox Code Playgroud)

如果(!pBox)检查怎么办?如果声明必要吗?

c++ pointers

1
推荐指数
1
解决办法
67
查看次数

C++获取HTML源代码

我想知道如何在不使用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)

c++ winsock

1
推荐指数
1
解决办法
6529
查看次数

Qt 等待 POST 完成

我将如何编写一个函数来等待 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)

c++ post qt http httprequest

1
推荐指数
1
解决办法
1178
查看次数

Lambda函数 - 按值捕获

为什么会导致分段错误?

#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递归地打电话?

c++ lambda

1
推荐指数
1
解决办法
118
查看次数

指向一组int的指针

有什么区别:

//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

c c++ arrays pointers

0
推荐指数
1
解决办法
192
查看次数

标签 统计

c++ ×5

pointers ×2

arrays ×1

assembly ×1

c ×1

http ×1

httprequest ×1

lambda ×1

post ×1

qt ×1

winsock ×1