用C语言编写一个程序!!!

2024-11-15 17:19:39
推荐回答(4个)
回答(1):

我帮你写一个吧。这是个简单的版本。其它的自己加上吧。
#include
#include
#define TrueID 111 //The macro can be changed as you wish.
#define TruePassword 000 //The macro can be changed as you wish.
#define Capacity1 400 //The macro can be changed as you wish.
#define Capacity2 400 //The macro can be changed as you wish.
int main()
{
int i;
char buf[Capacity1];
for(i=0;i buf[i]='\0';

char msg[Capacity2];
FILE* fp;
int ID,Password;
printf("Please input your ID:\n");
scanf("%d",&ID);
printf("\n");
printf("Please input your Password:\n");
scanf("%d",&Password);
printf("\n");
if(ID==TrueID && Password==TruePassword)
{
fp = fopen("c:\\file.txt", "r+");
fseek(fp, 0, SEEK_SET);
fread(buf, sizeof(char),500, fp);
printf("%s",buf);
printf("\nInput the text you want to add:\n");
getchar();
gets(msg);
fwrite(msg, strlen(msg)+1, 1, fp);
fclose(fp);
return 0;
}
else
{
fp = fopen("c:\\file.txt", "r");
fseek(fp, 0, SEEK_SET);
fread(buf, sizeof(char),500, fp);
printf("%s",buf);
printf("\n");
fclose(fp);
return 0;
}
}

回答(2):

有这样的程序啊,人家都那这个程序出书了。。

回答(3):

谁傻啊,不用记事本打开txt

回答(4):

记事本吧