小编Ada*_*dam的帖子

获取C++函数的大小

我正在阅读这个问题,因为我试图在C++程序中找到一个函数的大小,暗示可能有一种特定于平台的方法.我的目标平台是windows

我目前掌握的方法如下:
1.获取指向函数
的指针2.递增指针(和计数器),直到达到3的机器代码值ret
.计数器将是函数的大小?

编辑1:澄清我的意思'大小'我的意思是组成函数的字节数(机器代码).
编辑2:有一些评论询问为什么或我打算用这个做什么.诚实的答案是我没有意图,我无法真正看到了解函数长度预编译时间的好处.(虽然我确定有一些)

这对我来说似乎是一种有效的方法,这会有用吗?

c++ windows code-size

22
推荐指数
4
解决办法
1万
查看次数

将十进制转换为十六进制

首先,这是家庭作业.

我正在尝试将5位数字读入寄存器bx.假设该数字不大于65535(16位).以下是我试图这样做的方式.

但是,当我尝试打印数字时,我只打印输入的最后一个数字.这让我想到,当我向bx添加另一个号码时,它会覆盖以前的号码,但我无法看到问题.任何帮助将不胜感激,我几乎可以肯定它是一个小我忽略的东西: - /

mov cx,0x05 ; loop 5 times
    mov bx,0    ; clear the register we are going to store our result in
    mov dx,10   ; set our divisor to 10

read:
    mov ah,0x01     ; read a character function
    int 0x21        ; store the character in al
    sub al,0x30     ; convert ascii number to its decimal equivalent
    and ax,0x000F   ; set higher bits of ax to 0, so we are left with the decimal
    push ax         ; store …
Run Code Online (Sandbox Code Playgroud)

assembly nasm multiplication

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

如何从我的程序运行.exe并获取句柄

如何在C++中打开一个进程并获得一个句柄.我知道有system()很多方法可以获得句柄,但我确信有一种更简洁/替代的方法来做到这一点.或者是system()从你自己内部打开.exe的唯一方法?

c++ winapi

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

传染媒介问题传染媒介

我正在尝试遍历一个字符串列表,并在所述字符串中找到给定字符所在的位置.然后,我根据字符出现的位置/字符将字符串存储在给定的向量中.在循环完成执行之前,我在以下代码中遇到运行时错误.我已经看过它六次了,似乎找不到任何错误.

vector< vector<string> > p;
for(list< string >::iterator ix = dictionary.begin(); ix != dictionary.end(); ix++)
{
    int index = contains(*ix, guess);
    index++;

    p.at(index).push_back(*ix); //0 will contain all the words that do not contain the letter
                                //1 will be the words that start with the char
                                //2 will be the words that contain the the char as the second letter
                                //etc...
}



int contains(string str, char c)
{
    char *a = (char *)str.c_str();
    for(int i = 0; i < (str.size() + …
Run Code Online (Sandbox Code Playgroud)

c++ stl list vector

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

标签 统计

c++ ×3

assembly ×1

code-size ×1

list ×1

multiplication ×1

nasm ×1

stl ×1

vector ×1

winapi ×1

windows ×1