查看: 5041|回复: 10
收起左侧

PROGRAM

[复制链接]
发表于 2002-12-24 14:55:28 | 显示全部楼层 |阅读模式
#include"stdio.h"
main()
{
char a[20],b[20];
FILE *fp;
fp=fopen("code.txt","r");
if(fp==NULL)
{
  printf("\nfile cannot open");
  getch();
    }
  printf("\nplease input the code:");
  scanf("%s",b);
  fread(a,strlen(b),1,fp);
  if(strcmp(b,a)==0)
  {
   printf("\nthe code is right!");
   getch();
   }
   else
   {
    printf("\nwrong code!");
    }
     printf("%s",a);
     getch();
  }
发表于 2002-12-24 15:23:24 | 显示全部楼层

正确代码如下:

#include "stdio.h"
#include "conio.h"
#include "string.h"

void main(void)
{
char a[20],b[20];
FILE *fp;

fp=fopen("code.txt","r");
if(fp==NULL)
{
  printf("\nfile cannot open");
  getch();
}
printf("\nplease input the code:");
scanf("%s",b);
fread(a,strlen(b),1,fp);

////////////// 注意:下面这句不要忘记!字符串一定要以0字符结尾!
a[strlen(b)]=0;
//////////////

if(strcmp(b,a)==0)
{
  printf("\nthe code is right!");
  getch();
}
else
{
  printf("\nwrong code!");
}
printf("%s",a);
getch();
}
发表于 2003-2-5 13:59:36 | 显示全部楼层
什么玩意???????
发表于 2003-2-8 19:23:41 | 显示全部楼层
当然是 C 源代码了~~
呵呵~~
 楼主| 发表于 2003-5-31 20:05:52 | 显示全部楼层
字符是以0字符结尾呀!知道了。谢谢,我现在在学样跟外面比较脱节,想问一下学C语言的外面要不要?
发表于 2003-6-3 12:59:15 | 显示全部楼层
什么是C的外面?
呵呵~
 楼主| 发表于 2003-6-21 18:24:17 | 显示全部楼层
我是指就业呀!我现在还有一年就要毕业了,我比较关心就业呀!
发表于 2003-6-23 08:37:05 | 显示全部楼层
当然有用武之地了!
但要努力学习啊~~~~~~~
:)
 楼主| 发表于 2003-8-1 17:25:36 | 显示全部楼层
现在软件开发,大部分是要你干什么呢?
可以联系你的实际说说嘛?
发表于 2003-8-1 18:27:10 | 显示全部楼层
可以做很多内容啊~
比如我现在就在做数据库开发,用的是 VB。
只要有能力,没有找不到的工作!
:)
您需要登录后才可以回帖 登录 | 加入幸福家园

本版积分规则

快速回复 返回顶部 返回列表