|
|
源代码如下,问题是如果27,28,29行的yen改成其它,比如 dollar,franc,mark,pound都正常
但唯独用yen,编译正常,运行到最后一句就会出现 段错误 。
实在不理解是怎么回事,
谢谢来帮我解答的所有人。
我的这个程序中少了些错误判断语句,只是尽可能简化程序,希望能找出错误根源。
我的机器配置
赛扬4 1.7G
256 RAM
40G 硬盘
显卡MX400
操作系统:linux fc5
gcc 版本:4.1.1
1 #include<stdio.h>
2
3 #include<stdlib.h>
4
5 struct currency{
6 double dollar;
7 double yen;
8 double franc;
9 double mark;
10 double pound;
11 };
12 typedef struct currency Currency;
13 typedef Currency * currencyPtr;
14 void wrtData(currencyPtr *);
15
16 main()
17 {
18 currencyPtr curPtr=NULL;
19 wrtData(&curPtr);
20 return 0;
21 }
22
23 void wrtData(currencyPtr *rate)
24 {
25 FILE *fPtr=fopen("exchange","w");
26 *rate=malloc(sizeof(currencyPtr));
27 puts("input yen:\n");
28 scanf("%lf",&(*rate)->yen);
29 printf("%f",(*rate)->yen);
30 puts("!");
31 fclose(fPtr);
32 } |
|