Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

run time error

Posted on 2000-03-28
1
Medium Priority
?
203 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 60 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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 create, access, and change arrays in the C programming language.

610 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