c语言里小数点位置错误,如何在C语言中处理10位以上的小数点INT?

3

Rebaz salimi 3840221821 09188888888

4

95120486525

95120482642

95120541325

95120860452

即时阅读它变成数组对象从struct books和struct MEMBERS并打印出的screen.here是我的代码:

struct books

{

long long int id;

char stname[20];

char name[20];

char Author[20];

int quantity;

float Price;

int count[100];

int code[100];

int rackno;

char *cat;

struct meroDate issued;

struct meroDate duedate;

};

struct MEMBERS

{

long long int code;

char Fname[40];

char Lname[40];

long long int Pnum;

float bedeh;

float credit;

struct meroDate issued;

struct meroDate duedate;

};

struct MEMBERS cur_member[100];

struct books cur_book[100];

int main()

{

getdataMEMBERS();

return 0;

}

int getdataMEMBERS()

{

FILE *myfile = fopen("Members.txt", "r");

FILE *myfile1 = fopen("Members.txt", "r");

if (myfile == NULL) {

printf("Cannot open file.\n");

return 1;

}

else {

char ch;

int count = 0;

do

{

ch = fgetc(myfile);

if (ch == '\n') count++;

} while (ch != EOF);

rewind(myfile);

//Since you put 2 earlier in the member.txt we need to dump it

//so that it wont affect the scanning process

int temp;

fscanf(myfile, "%d", &temp);

printf("%d\n", temp);

//Now scan all the line inside the text

int i;

for (i = 0; i < 1; i++) {

fscanf(myfile, "%s %s %lld %lld\n %d", cur_member[i].Fname,

cur_member[i].Lname, &cur_member[i].code, &cur_member[i].Pnum

,&cur_book[i].quantity);

printf("%s %s %lld %lld\n

%d\n",cur_member[i].Fname,cur_member[i].Lname,

cur_member[i].code,cur_member[i].Pnum , cur_book[i].quantity);

int j;

for(j=0;j

{

fscanf(myfile,"%d\n",&cur_book[j].id);

printf("%d\n",cur_book[j].id);

}

}

}

fclose(myfile);

}

一旦我printf这代码:

int j;

for(j=0;j

{

fscanf(myfile,"%d\n",&cur_book[j].id);

printf("%d\n",cur_book[j].id);

}

它给我:

631206013

631202130

631260813

631579940

应该想给我:

95120486525

95120482642

95120541325

95120860452

我已经改变了数据类型在struct bookslong long double id;但仍然gaves我这三个输出:

631206013

631202130

631260813

631579940

会有人知道在哪里问题可能是?数据类型还是别的?

2017-06-29

moh89

+1

有没有必要对这些数字进行计算?如果没有,只需存储*字符串*。 'double'不会使整数产生任何*意义,只会失去精度。为更广泛的'int'尝试'long long'。 –

+0

为什么'long long double'(它不是作为一个类型存在,你的意思是'long double'')而不是'long long int',它在支持的系统上至少有64位? –

+1

您正在用'%d'转换说明符打印(并扫描)一个'long long int'? –

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值