我试图编写一个小代码bruteforce程序。但是我不能编译它。我认为这是一个非常简单的programmcode,这就是为什么它使我如此困扰以至于无法编译的原因。我在寻找解决方案,但无法赚钱。
`1 #include <stdio.h>
2 #include <string.h>
3 char pass;
4 strcpy(pass,"m");
5 int pass_test(int argc, char *argv[]){
6 char s_pass[2];
7 argv[0] = s_pass;
8 if (s_pass == pass){
9 printf("=================\n==Access gained==\n=================");
10 }
11 else{
12 printf("sth. went wrong");
13 }
14 }
15 int main(){
16 char solved_pass[2];
17 char *OP_ABC;
18 int i, p, z;
19 strcpy(OP_ABC, "abcdefghijklmnopqrstuvwxyz");
20 if ((strlen(pass)) == 1){
21 for(i=0;i < strlen(OP_ABC);i++){
22 pass_test(OP_ABC[i]);
23 }
24 }
25 if (strlen(pass) == 2){
26 for(p=0;p < strlen(OP_ABC);p++){
27 for(z=0;z < strlen(OP_ABC);z++){
28 OP_ABC[p] = solved_pass[0];
29 OP_ABC[z] = solved_pass[1];
30 pass_test(solved_pass);
31 }
32 }
33 }
34 }`
这就是编译器所说的
bruteforce.c:4:13: error: expected ‘)’ before string constant bruteforce.c: In function ‘pass_test’: bruteforce.c:8:13: warning: comparison between pointer and integer [enabled by default] bruteforce.c: In function ‘main’: bruteforce.c:20:2: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast [enabled by default] In file included from bruteforce.c:2:0: /usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘char’ bruteforce.c:22:4: error: too few arguments to function ‘pass_test’ bruteforce.c:5:5: note: declared here bruteforce.c:25:2: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast [enabled by default] In file included from bruteforce.c:2:0: /usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘char’ bruteforce.c:30:5: warning: passing argument 1 of ‘pass_test’ makes integer from pointer without a cast [enabled by default] bruteforce.c:5:5: note: expected ‘int’ but argument is of type ‘char *’ bruteforce.c:30:5: error: too few arguments to function ‘pass_test’ bruteforce.c:5:5: note: declared here
有人可以帮我吗?
最佳答案
一个问题是,您不能在全局范围内使用语句或自由表达式。
另一个问题是strcpy
函数期望字符串(即char*
)作为目标,而不是单个char
。
您可以通过一行定义和初始化来解决这两个问题:
char pass = 'm';
关于c - bruteforce代码未运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29801243/