c - 我缺少什么,所以我可以编译我的源代码?我是新手

标签 c compiler-errors command

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

 #define password "Please enter your password"

int main(int arge, char *argv[])
(
  char pass[100];


  printf("Please enter your password\n\n");
  scanf("is", pass);
  if ( stromp(pass, passsword) == 0 )
  (
       printf("Congrats!! Correct Pass\n\n");

  { else}

      printf("Wrong Pass\n\n");
   )

   system("PAUSE");
   return 0;
)       

所以我不确定它出了什么问题,我已经完全坚持了两天,每当我尝试编译它时,我都会得到这个:

prog.c:12:3: error: expected declaration specifiers or '...' before 'printf'
       printf("Please enter your password\n\n");
       ^
    prog.c:13:3: error: expected declaration specifiers or '...' before 'scanf'
       scanf("is", pass);

   ^
prog.c:14:3: error: expected declaration specifiers or '...' before 'if'
   if ( stromp(pass, passsword) == 0 )
   ^

prog.c:24:4: error: expected declaration specifiers or '...' before 'return'
    return 0;
    ^

prog.c:7:5: error: 'main' declared as function returning a function
 int main(int arge, char *argv[])
     ^

prog.c: In function 'main':
prog.c:25:1: error: expected '{' at end of input
 )         
 ^


prog.c:25:1: warning: control reaches end of non-void function [-Wreturn-type]
 )         
 ^

你能告诉我它应该是什么样子吗?

最佳答案

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

  int main(int argc, char *argv[])
  {
     char pass[100];
     char password[]="9009875316";
     printf("Please enter your password\n\n");
     fgets(pass,100,stdin);
     if (!(strcmp(pass, password)))
     {
        printf("Congrats!! Correct Password\n\n");
        // your code if entered password is correct..
     }
     else
     {
        printf("Wrong Password\n\n");
        // your code if entered password is wrong..
     }
     return 0;
  }

Basic_Syntax

Input_Output

Learn C

关于c - 我缺少什么,所以我可以编译我的源代码?我是新手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31633887/

相关文章:

string - Swift - String substringWithRange - 'String' 不可转换为 '()'

wpf - 在上下文菜单中分组

c - 在 C 中通过管道将一个命令的输出作为另一个命令的输入

c - 将新部分插入二进制文件?

C编程指针数组读取文件

c - 在c中用typedef声明函数时,我们如何消除未声明的函数错误?

c# - 从.NET Core项目引用.net标准程序集会导致引用错误

Laravel 5 命令 - 一个接一个地执行

c - 标准 C - 如何使用 1970 年 1 月 1 日以外的 unix 纪元时间戳?

c - 如何在 OS X 10.10.1 上正确安装 cs50.h 库?