鱼C论坛

 找回密码
 立即注册
12
返回列表 发新帖
楼主: 我叫学得会

[已解决]其他函数模块如何调用主函数argv参数值?

[复制链接]
 楼主| 发表于 2021-4-13 15:26:03 | 显示全部楼层
yuxijian2020 发表于 2021-4-12 19:35
那你就把

这一句放到Invoke()函数的定义前面

大佬,全局变量总是不运行,我试试用你说的传参吧,你看看下面该如何修改




#include <iostream>
#include <windows.h>
#include <string>
#include "b64/base64.h"

//传进参数:geturl: http://www.baidu.com/

using namespace std;

int main(int argc, char** argv[])
{
        if (argc != 2)
        {
                return -1;
        }
        else if(argv[1] == 1)
        {
                test1();
                return 0;
        }
        else
        {
                return -1;
        }
}


void test1()
{
        Sleep(3000);
        while (true) {
                try {

                        test2();
                        Sleep(20000);
                }
                catch (const std::exception& e)
                {

                }

        }
        return;
}

void test2()
{
        sting endurl = endbase64(geturl);
        return;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-4-13 15:36:01 | 显示全部楼层
yuxijian2020 发表于 2021-4-12 19:35
那你就把

这一句放到Invoke()函数的定义前面

大佬,全局变量一直未调用成功,请问 传参进子子函数该如何修改,请看代码:


#include <iostream>
#include <windows.h>
#include <string>
#include "b64/base64.h"

//传进参数:geturl: http://www.baidu.com/

using namespace std;

int main(int argc, char** argv[])
{
        if (argc != 2)
        {
                return -1;
        }
        else if(argv[1] == 1)
        {
                test1();
                test3();
                return 0;
        }
        else
        {
                return -1;
        }
}


void test1()
{
        
        while (true) {
                try {

                        test2();
                        
                }
                catch (const std::exception& e)
                {

                }

        }
        return;
}

void test2()
{
        MessageBox(NULL, TEXT(geturl), TEXT("帮助"), MB_OK);;
        return;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-21 17:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表