Solved

run-time error

Posted on 2000-03-28
2
186 Views
Last Modified: 2010-05-19
I have the following program code that read a text file and store it into a array of structure declare as below
compliation is success but when runnung the program a error 'scanf : floating point formats not linked'

#include <stdio.h>
#include <string.h>
void main()
{
    struct score
    {
        float money;
        char name[4];
    };
    struct score ming[11];
    int count, index;
    int exchange_count, pass, check;
    int start, middle, end, found, value;
    char temp[4], input_data[4];

    FILE *fp;
    fp = fopen("datafile.txt","r");
    for ( count = 1; count <= 10; count++ )
     fscanf(fp,"%s  %f",&ming[count].name,&ming[count].money);
     fclose(fp);
}


0
Comment
Question by:adrianmak
2 Comments
 

Expert Comment

by:sasson
ID: 2666130
Hi

U can try this code:


if (!((fp = fopen("datafile.txt","r"))==NULL))
{
    for ( count = 1; count <= 10;   count++ )
     fscanf(fp,"%s  %f",&ming[count].name,&ming[count].money);
     fclose(fp);
}
else
   printf("Error whatsoever....");

your file may not be opened.
0
 
LVL 10

Accepted Solution

by:
rbr earned 20 total points
ID: 2667831
USe
  fscanf(fp,"%s  %f",ming[count].name,&ming[count].money);

ming[count].name is already a pointer no & needed.

And some compilers have problems in using the floating point expansion.

Try
void main()
{
    float dummy=1.0;
as your first main line.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now