Solved

sscanf and struct...

Posted on 1998-09-23
7
633 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
libcurl and C++ - Post JSON Data 8 1,182
voltage to force translation ? 8 97
UPD maximums on Red Hat 6 109
convert char array to number in c 5 83
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 use strings and some functions related to them in the C programming language.

932 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

17 Experts available now in Live!

Get 1:1 Help Now