用TC2.0弄不出来。把“2005000000”0“666666”到“2005999999”0“666666”输如到文件1中,写到“2005000015”0“666666”就没法写了,fopen()返回NULL,用VC++6.0写进去的多一点,但也无法写完,怎么回事啊?
弄了昨天一天了,网上也找不到答案,救救啊!
源程序:
#include<stdio.h>
typedef struct{
char count[10];
unsigned long money;
char password[6];
} userdata;
void main()
{
int i,j,k,l,m,n;
FILE *fp;
for(i=0;i<10;i++)
{
userdata num={"2005000000",0,"666666"};
num.count[4]=i+'0';
for(j=0;j<10;j++)
{
num.count[5]=j+'0';
for(k=0;k<10;k++)
{
num.count[6]=k+'0';
for(l=0;l<10;l++)
{
num.count[7]=l+'0';
for(m=0;m<10;m++)
{
num.count[8]=m+'0';
for(n=0;n<10;n++)
{
num.count[9]=n+'0';
if((fp=fopen("1","ab"))==NULL)
{
printf("Sorry! Data is wrong,Please connect the bank!\n");
exit(0);
}
if(fwrite(&num,20,1,fp)!=1)
{
printf("Sorry Data is wrong,Please connect the bank!\n");
exit(0);
}
}
}
}
}
}
}
fclose(fp);
}
[此贴子已经被作者于2006-9-17 12:46:34编辑过]