Solved

run time error

Posted on 2000-03-28
1
201 Views
Last Modified: 2010-04-02
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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
hongjun earned 20 total points
ID: 2666096
Your fscanf should be in this way
fscanf("%s %f", ming[count].name, &name[count].money);

Another possibility is you must make sure that the records in your text file must be in the below standard:
name1 99
name2 88

Another problem in your program is that you should use the for loop in the below way
for ( count=0; count<10; i++ )
index for array starts at 0 and not 1. The above for loop will loop 10 times and occupy array from 0-9.
Another thing to make sure is that you should make sure that the text file has at least 10 records altogether.

I suggest you using the below loop to read the file
while ( !(feof(fp) )
{
    fscanf(...);
}

hongjun
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

717 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