Solved

sscanf and struct...

Posted on 1998-09-23
7
635 Views
Last Modified: 2008-03-17
Hi there I've got a problem with a C-programm which uses sscanf to fill a struct with several data.

struct type{char string; double dvar1;} name;
char buffer[82]; double local;
...
main(){
for(loop=0;loop <5;++loop){
...  
gets(buffer);
sscanf(buffer,"%s",&name[loop].string);// works fine
gets(buffer);
sscanf(buffer,"%lf",&name[loop].dvar1);// does not work; error message: floating point formats not linked
//if I use:
gets(buffer);
sscanf(buffer,"%lf",&local);
name[loop].dvar1)=local; //it works fine

can you give me a hint, what I do wrong.( By the way using BC for DOS).
thanx
greetings x-rai
0
Comment
Question by:x_rai
7 Comments
 
LVL 3

Expert Comment

by:danny_pav
ID: 1252983
is that a compiler error or runtime error?
0
 

Author Comment

by:x_rai
ID: 1252984
It 's a runtime error... followed by the comment abnormal termination.
:(

0
 
LVL 3

Expert Comment

by:plaroche
ID: 1252985
How can you use:

name[loop]

when you haven't allocated more than one slot for that structure?
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:x_rai
ID: 1252986
It 's a runtime error... followed by the comment abnormal termination.
:(

0
 

Author Comment

by:x_rai
ID: 1252987
>How can you use:
>
>      name[loop]
>
>       when you haven't allocated more than one slot for that structure?
sorry -typed it by head, in the programm it is of course
struct type{char string; double dvar1;} name[5];

But thats not the point
0
 
LVL 3

Accepted Solution

by:
zhongbing earned 100 total points
ID: 1252988
hi.
struct type{char string; double dvar1;} name[5];
should be
..........char string[xxxx];.......
cause you refered it like a string not a single char.
0
 

Author Comment

by:x_rai
ID: 1252989
Hi,
this is a rigth invention, but not the solution to the problem.
Infact I found out that it is a compiler error, from Borland, where the compiler optimizes the executable file as small as possible.
This is solved by inserting
extern void _floatconvert();
#pragma extref _floatconvert()
into the source.
found in the technical information of borland, (with help of Hans-Bernhard Broeker) located at:
http://www.inprise.com/devsupport/borlandcpp/ti/TI645.html
thanks for your help
cheers rai

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

785 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