开发者

Pointer notation question

I am using TurboC. What's wrong with this code? During the runtime, the message was "floating point formats not linked" "Abnormal program termination". I am a newbie in C language, and I've never encountered this kind of error before. Thanks in advance!

/* averages arbitrary number of temperatures */
/* uses pointer notation */
main()
{
     float temper[40];                                  /* Array declaration */
     float sum=0.0;
     int num, day=0;

     do                                                 /* Puts temps in array */
     {
         printf("Enter temperature 开发者_如何学Cfor day %d: ", day);
         scanf("%f", temper+day);
     }
     while( *(temper+day++) > 0 );

     num = day-1;                                       /* number of temps entered */
     for(day=0; day<num; day++)                         /* calculate average */
          sum += *(temper+day);
     printf("Average is %.1f", sum/num);

     getche();
}


Please see this FAQ: Turbo C program which crashes and says something like "floating point formats not linked."

The solution they suggest is to add a dummy call to the sqrt function so that the compiler/linker detects that you need floating point support linked in. I would expect there to also be an option for your compiler and/or IDE that you could set instead, but I don't know anything about about Turbo C.


You need to enable linking floating point library in TurboC, from options>linkers>library>floating point.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜