Solved

sscanf and struct...

Posted on 1998-09-23
7
630 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
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 and use conditional statements in the C programming language.

759 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

20 Experts available now in Live!

Get 1:1 Help Now