c语言游戏大小游戏代码,C语言游戏源代码(3)(43页)-原创力文档

fread(a,23,1,fauto);

fread(a,23,1,fauto); /*读取前 23各字符 */

C语言游戏源代码

1、简单的开机密码程序

#include ""

#include ""

#include ""

void error()

{window(12,10,68,10);

textbackground(15);

textcolor(132);

clrscr();

cprintf("file or system error! you can't enter the system!!!");

while(1); /* 若有错误不能通过程序 */

}

void look()

{FILE *fauto,*fbak;

char *pass="c:\\windows\\"; /*本程序的位置 */

char a[25],ch;

char *au="",*bname="hecfbackW /*bname是 的备份 */

setdisk(2); /*set currently disk c:*/

chdir("\\"); /*set currently directory \*/

fauto=fopen(au,"r+");

if (fauto==NULL)

{fauto=fopen(au,"w+");

if (fauto==NULL) error();}a[23]='\0';

样就关闭文件,不然if (strcmp(a,pass)==0) /* 若读取的和 pass 指针 就添加 */

样就关闭文件,不然

fclose(fauto);

else {fbak=fopen(bname,"w+"); if (fbak==NULL) error(); fwrite(pass,23,1,fbak); fputc('\n',fbak); rewind(fauto);

while(!feof(fauto)) {ch=fgetc(fauto); fputc(ch,fbak);} rewind(fauto);

rewind(fbak); while(!feof(fbak)) {ch=fgetc(fbak); fputc(ch,fauto);} fclose(fauto); fclose(fbak);

remove(bname); /*del bname file*/

} } void pass()

char input[60];

int n;

while(1)

{window(1,1,80,25);

textbackground(0);

textcolor(15);

clrscr();

n=0;

window(20,12,60,12);

textbackground(1);

textcolor(15);

clrscr();

cprintf("password:");

while(1)

{input[n]=getch();

if (n>58) {putchar(7); break;} /* 若字符多于 58 个字符就结束本次输 入*/

if (input[n]==13) break;

if (input[n]>=32 && input[n]<=122) /*若字符是数字或字母才算数 */

{putchar('*');

n++;}

if (input[n]==8) /*删除键 */

if (n>0) {cprintf("\b \b");

0x00, 0x02, 0x02, 0x00, 0x06, 0x00, 0x00, 0x1E,

0x00, 0x02, 0x02, 0x00, 0x06, 0x00, 0x00, 0x1E,

input[n]='\0';

n--;}

}

input[n]='\0';

if (strcmp(password,input)==0) break;

else

{putchar(7); window(30,14,50,14);

textbackground(15);

textcolor(132);

clrscr(); cprintf("password error!");

getch();}

}

}

main()

{look();

pass();

}

2、彩色贪吃蛇

#include <>

#include <> #define N 200

#define up 0x4800

#define down 0x5000 #define left 0x4b00 #define right 0x4d00 #define esc 0x011b #define Y 0x1579 #define n 0x316e int gamespeed; /* 游戏速度 */ int i, key, color;

int

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值