Solved

sscanf and struct...

Posted on 1998-09-23
7
637 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
undefined reference to `bswap_128' 9 169
mixing C++ and C code elegantly 10 158
Coverting 24 hour time to 12 hour in C++ 15 178
Using ANSI C how to Read a .csv file 10 93
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

789 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