91学习

陪伴你每一天!

ftell()函数模拟设置银行卡号

#include <stdio.h>

#include <process.h>


int main(){

int n;

FILE *fp;

char ch,str[30],filename[30];

printf("please input the filename:\n");

scanf("%s",filename);

if((fp=fopen(filename,"w"))==NULL){

printf("can not open filename:\n");

exit(0);

}

printf("please input the number:\n");

getchar();

gets(str);

fputs(str,fp);

fclose(fp);


if((fp=fopen(filename,"r"))==NULL){

printf("can not open filename:\n");

exit(0);

}

ch=fgetc(fp);

while(ch!=EOF){

putchar(ch);

ch=fgetc(fp);

}

printf("\n");

n=ftell(fp);

if(n==6){

printf("密码设置成功\n");

}else{

printf("密码设置失败\n");

}

fclose(fp);

return 0;

}

加威信18790284560免费送POS机.jpg

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。