小编Ant*_*ton的帖子

将字符串转换为数学评估

好的,所以我想要做的是使用字符串作为输入(例如"16*12 + 25"),将其转换为计算机可以理解的数学评估并返回评估值.我本可以自己写这个,但它很可能需要一段时间,最后,它仍然不会像我想的那样结束,除非我想把更多的时间投入其中.

所以我的问题是,你知道可以为C++做任何脚本,库或API吗?我找到了一些java,python和.NET.但是我没有使用这些语言,我希望尽可能长时间地保持在C++中(希望在整个项目中).你有什么好主意或链接吗?

c++ string math

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

如何捕获部分屏幕并将其保存到BMP?

可能重复:
如何在c ++中使用win32制作屏幕截图?

我目前正在尝试创建一个将屏幕的一部分保存到bmp的应用程序.我找到了BitBlt,但我真的不知道该怎么做.我试过寻找一些答案,但我还没有找到一个使用C++澄清的答案.

所以,基本上我想要这个功能:

bool capturePartScreen(int x, int y, int w int, h, string dest){
    //Capture part of screen according to coordinates, width and height.
    //Save that captured image as a bmp to dest.
    //Return true if success, false if failure
}
Run Code Online (Sandbox Code Playgroud)

BitBlt的:

BOOL BitBlt(
    __in  HDC hdcDest,
    __in  int nXDest,
    __in  int nYDest,
    //The three above are the ones I don't understand!
    __in  int nWidth,
    __in  int nHeight,
    __in  HDC hdcSrc,
    __in  int nXSrc,
    __in  int …
Run Code Online (Sandbox Code Playgroud)

c++ winapi bmp screen-capture

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

函数strcpy()改变整数数组的值?

我将从我目前的代码开始,其中输入是用户提供的变量:

int current[2] = {-1, -1}, next[2] = {-1, -1};
char *strtok_result = strtok(input, " ");
int i = 0;
while(strtok_result != NULL){
    i++;
    int count = 0;
    char strtok_buffer[2];
    printf("iteration %d-%d: next[0] = %d\n", i, ++count, next[0]);
    strcpy(strtok_buffer, strtok_result);
    printf("iteration %d-%d: next[0] = %d\n", i, ++count, next[0]);

    current[0] = next[0];
    current[1] = next[1];
    next[0] = strtok_buffer[1] - 48;            // ascii conversion, digit to column
    next[1] = toupper(strtok_buffer[0]) - 64;   // --- || ---, letter to row
    printf("iteration …
Run Code Online (Sandbox Code Playgroud)

c memory arrays strcpy

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

"相同"语法,使用mysqli fetch_assoc()的结果不同?

所以,这不是需要解决的问题,而是出于好奇和缺乏澄清的问题.A正在努力处理一块php/mysqli,在调试和拆分代码时,我发现我的代码工作正常,而不是我写的方式.

初始代码(不工作)

$result = $mysqli -> query("SELECT nick FROM userdata WHERE id=".$_SESSION['uid']);
// ... error checking here ...
for($i = $result -> num_rows - 1; $i >= 0; $i--){
    $result -> data_seek($i);
    $nick = ($result -> fetch_assoc())['nick']; // crash
}
Run Code Online (Sandbox Code Playgroud)

最终代码(工作)

$result = $mysqli -> query("SELECT nick FROM userdata WHERE id=".$_SESSION['uid']);
// ... error checking here ...
for($i = $result -> num_rows - 1; $i >= 0; $i--){
    $result -> data_seek($i);
    $row = $result -> fetch_assoc(); // working
    $nick = …
Run Code Online (Sandbox Code Playgroud)

php mysql mysqli

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

RegEnumValue崩溃了应用程序

我目前正在学习如何使用c ++使用注册表.我已经创建了一个应用程序,可以查看某个键中是否存在某个值.但是,应用程序一到达RegEnumValue()就会崩溃.对问题可能是什么的任何想法?

码:

#include <iostream>
#include <windows.h>
#include <Psapi.h>

using namespace std;

bool registerKeyExists(char* key, char* subkey);

int main()
{
    while(true){
        if(registerKeyExists("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "SynTPEnh")){
            return 0;
        }
    }

    return 0;
}

bool registerKeyExists(char* key, char* subkey){
    HKEY keyEnum;
    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &keyEnum) == ERROR_SUCCESS){
        char* valueName;
        DWORD valueSize = 100;
        DWORD cbName;
        FILETIME lastFiletime;
        DWORD i = 0;
        DWORD returnCode = ERROR_SUCCESS;
        while(returnCode == ERROR_SUCCESS){
            cout << "This show!" << endl;
            returnCode = RegEnumValue(keyEnum, i, valueName, &valueSize, NULL, NULL, NULL, …
Run Code Online (Sandbox Code Playgroud)

c++ registry winapi

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

标签 统计

c++ ×3

winapi ×2

arrays ×1

bmp ×1

c ×1

math ×1

memory ×1

mysql ×1

mysqli ×1

php ×1

registry ×1

screen-capture ×1

strcpy ×1

string ×1