C 对,我有这个代码,系统命令总是出错

C 对,我有这个代码,系统命令总是出错,c,C,我正试图制造一种野蛮的力量 #include <string.h> #include <stdio.h> #include <stdlib.h> int main() { int i; while (i <= 999999 ) { system("./lock", i); i++; } printf("Error. Unab

我正试图制造一种野蛮的力量

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
        int i;
        while (i <= 999999 ) {
                system("./lock", i); 
                i++;
        }
        printf("Error. Unable to crack file.\n");
        return 0;
}
但是如果你知道一种检测它是否被破解的方法,也请加上它。如果可以。

#包括
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i = 0;
    while (i <= 999999 )
    {
        char cmd[100];
        sprintf(cmd, "./lock %d", i);
        if (system(cmd) == 0)
        {
            printf("Success with i = %d\n", i);
            exit(0);
        }
        ++i;
    }
    return !printf("Error. Unable to crack file.\n");
}
#包括 #包括 int main() { int i=0;
而(i)编译器应该警告您正在使用未初始化的变量
i
,并且
system()
有太多的参数。我使用的是man 3系统。它并没有帮助所有人。我在google上搜索了5个小时才找到问题,但我仍然看不到问题。我得到了,。错误消息不够清楚吗?5个小时,而你没有发现
系统
不能接受两个参数??它只接受一个参数。你是负责将所有输入合并到一个参数中。(参见我的答案和
sprintf
的使用)我想知道
sprintf
是否与
sprintf\u s
相混淆。它工作正常,但在第一次尝试时就停止了。我正在试图找到一种方法来解决这个问题。然后,您没有足够详细地描述
锁定程序的功能,或者它成功的时间,或者它的功能。
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i = 0;
    while (i <= 999999 )
    {
        char cmd[100];
        sprintf(cmd, "./lock %d", i);
        if (system(cmd) == 0)
        {
            printf("Success with i = %d\n", i);
            exit(0);
        }
        ++i;
    }
    return !printf("Error. Unable to crack file.\n");
}