c语言gets函数编译出错,一个关于gets函数的奇怪问题 无人能解··

我不知道你是什么编辑器,我用的是dev C++ 发现new是一个关键字,还有许多函数应用没有用头文件

/*网页上的程序*/

#include

#include

#include

#include

typedef    struct worker

{

int num;

char name[20];

char sex;

int age;

}Linklist;

void ccode(char * , int *);

void menu();

int main(void)

{

void menu();

void ccode();

menu();

}

void menu()

{

int choose,flag=0,i;

char *p1;

int *p2;            /*密码  和 标志  都改变其值*/

char code[10],change[]="520",ch;

p1=change;

p2=&flag;

Start:                                                                      /*为了让密码 不在重置*/

printf("                        Workers Information Query System\nPlease give the code to enter the System:");

for( ; flag == 0 ; )

{

for(i=0 ; ((ch=getch())!='\r') && (i < 10 ); i++)                /*回车是/r 换行才是/n*/

{

code[i]=ch;

printf("*");

}

code[i]='\0';                                     /*  记住在这里的后面加上一个结束的标识符*/

if(strcmp(code,p1)==0)                    /*这里用不用指针都没有关系*/

{

flag=1;

}

else

printf("\nSorry! the code you give is wrong,please re-enter it as confirmation:\n");

}

system("cls");

printf("                          Workers Information Query System\nPlease choose the survice as follow:\n  1.Information for all workers\n  2.Workers search\n  3.Change the information of workers\n");

printf("  4.Adding workers\n  5.Password reset\n  6.Dismiss workers\n  7 End");

scanf("%d",&choose);

switch(choose)

{

case 5:ccode(p1,p2);goto Start;

}

}

void ccode(char *p1 , int *p2)

{

char old[10];

char new1[10];

printf("Please input the old password:");

/*gets(old);*/

scanf("%s",old);

if(strcmp(old,p1)!=0)

{

menu();                    /*如果输入不正确 就要返回菜单 这个设置 应该在完善一下*/

}

else

{

printf("Please input the new password:");

gets( new1 );

strcpy(p1 , new1);

*p2=0;

}

printf("Succee!\n");

system("pause");

system("cls");

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值