Hi myself vandana. I wanna know how can we use float variables with in C structures. Can anyone help me.
12 13834
Hi myself vandana. I wanna know how can we use float variables with in C structures. Can anyone help me.
Hi Vandana,
The question seems to be generic. It would be useful to suggest when it is more specific.
Hi myself vandana. I wanna know how can we use float variables with in C structures. Can anyone help me.
have a look at this tutorial on Data Structures
http://www.cplusplus.com/doc/tutorial/structures.html
Hi Vandana,
The question seems to be generic. It would be useful to suggest when it is more specific.
hello ji,
Actually i wanna write a program who can accept data of 10 players and sort them and display result team wise. when i started i write code to scan details.
but it gives message at runtime while entering first floating value that floating point formats not linked abnormal program termination.
i m sending my code of program -
#include<stdio.h>
-
#include<conio.h>
-
#include<string.h>
-
struct player_detail
-
{
-
char player_name[15];
-
char team_name[15];
-
float batting_avg;
-
}players[10];
-
void main()
-
{
-
int i,x;
-
for(i=0;i<3;i++)
-
{
-
printf("\nEnter Player Name : ");
-
gets(players[i].player_name);
-
printf("\nEnter Team : ");
-
gets(players[i].team_name);
-
printf("\nEnter Batting Average : ");
-
scanf("%f",&players[i].batting_avg);
-
}
-
}
this is a problem with Visual C where it does not load floating point support if it does not think it necessary, see
http://msdn2.microsoft.com/en-us/library/k1x26e0x.aspx
try putting a dummy floating point assignment in the program to force loading of the support, e.g. -
int main()
-
{
-
int i,x;
-
float z=10.0f;
-
this is a problem with Visual C where it does not load floating point support if it does not think it necessary, see
http://msdn2.microsoft.com/en-us/library/k1x26e0x.aspx
try putting a dummy floating point assignment in the program to force loading of the support, e.g. -
int main()
-
{
-
int i,x;
-
float z=10.0f;
-
Hi,
i m using C++ compiler of versoin 3.0. & this is also giving the same Problem.
Will u please tell me how i can use float in structures while using same compiler.
Hi,
i m using C++ compiler of versoin 3.0. & this is also giving the same Problem.
Will u please tell me how i can use float in structures while using same compiler.
did you try defining a float to force loading of the libraries? e.g. -
int main()
-
{
-
int i,x;
-
float z=10.0f;
is it Visual C++ V3.0 or another compiler?
did you try defining a float to force loading of the libraries? e.g. -
int main()
-
{
-
int i,x;
-
float z=10.0f;
is it Visual C++ V3.0 or another compiler?
it is turbo c++.
it is turbo c++.
it appears in Turbo C V3.0 you have to force loading of the floating point conversions, see
http://www.vmlinux.org/~jakov/community.borland.com/15204.html
it recommends that you include the following function in your code - you don't need to to call it -
static void force_fpf()
-
{
-
float x, *y; /* Just declares two variables */
-
y = &x; /* Forces linkage of FP formats */
-
x = *y; /* Suppress warning message about x */
-
}
-
it appears in Turbo C V3.0 you have to force loading of the floating point conversions, see
http://www.vmlinux.org/~jakov/community.borland.com/15204.html
it recommends that you include the following function in your code - you don't need to to call it -
static void force_fpf()
-
{
-
float x, *y; /* Just declares two variables */
-
y = &x; /* Forces linkage of FP formats */
-
x = *y; /* Suppress warning message about x */
-
}
-
Thx ur advice works. thx again for sending this article.
Hi,
i m using C++ compiler of versoin 3.0. & this is also giving the same Problem.
Will u please tell me how i can use float in structures while using same compiler.
vandanasridhar hi
I have the problem to.it was simple just use a dumi float variable out of the structure then assign the value and use the variable;
struct dum{
int a;
float f;
----------
---------
};
int dum_f = f ;
@vandanasridhar
Hi Vandana
Don't worry
There is simple solution for ur problem when getting the error
"scanf : floating point formats not linked
Abnormal program termination"
just add the two given lines in ur program extern void _floatconvert();
#pragma extref _floatconvert
and enjoy it
one example code is given - #include<stdio.h>
-
-
-
extern void _floatconvert();
-
#pragma extref _floatconvert
-
-
-
-
struct stud
-
{ char name[50];
-
float m1, m2, m3, total;
-
}s[10];
-
void main()
-
{
-
int n,i;
-
clrscr();
-
printf("How many students? \t");
-
scanf("%d",&n);
-
for(i=0;i<n;i++)
-
{
-
printf("\nGive name of student%d:\t",i+1);
-
scanf("%s",s[i].name);
-
printf("\nGive 3 marks of %s\t",s[i].name);
-
scanf("%f%f%f",&s[i].m1,&s[i].m2,&s[i].m3);
-
s[i].total = s[i].m1 + s[i].m2 + s[i].m3;
-
}
-
printf("\nNAME\t\tMARK1\tMARK2\tMARK3\tTOTAL");
-
for(i=0;i<n;i++)
-
{
-
printf("\n%s\t\t%0.2f\t%0.2f\t%0.2f\t%0.2f",s[i].name, s[i].m1, s[i].m2, s[i].m3, s[i].total);
-
}
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bernard Delmée |
last post by:
Is there a simple way to modify the default sprintf mask
used for floats ? (eg something like sys.float_mask = '%.2f')
I've tried assigning to float.__dict__, but
that's apparently not allowed.
|
by: kazack |
last post by:
Hi all it's me again with another question as I got further in my book. The
chapter I am in covers structres, abstract data and classes. I only read
through to the end of the coverage on...
|
by: Maciej |
last post by:
Hello I have some problems with converting varbinary to float in T-SQL
stored procedure. In my C# application i have table of structures with
double type fields. Size of this table is variant. I...
|
by: Ken Allen |
last post by:
OK, I admit that I have been programming since before C++ was invented,
and I have developed more than my share of assembly language systems,
and even contributed to operating system and compiler...
|
by: pmclinn |
last post by:
I've noticed that many programmers use classes to store data about such
things like:
Class Customers
.....Phone
....ID
....Address
End Class....
|
by: ljlevend2 |
last post by:
I need to create TypeConverters for the floating type drawing structures
(i.e., PointF, SizeF and RectangleF) that behave exactly as their integer
couterparts (e.g., System.Drawing.PointConverter)....
|
by: thomasfarrow |
last post by:
At work, our development team has a development standards document that
insists Structures should never be used. I'm looking to change this
standard but need a suitable argument in order to make...
|
by: Carramba |
last post by:
Hi!
I now that I can't do straight forward any bitwise operation on float
(double etc..). But I wondering what is the easiest/best way to do this?
I was thinking if I have float x=1.1111 so I can...
|
by: durgavaraprasad |
last post by:
Hi I'm prasad.
I am new to structures in C.
I declared a structure as follows.
But it is giving a run-time error that
"scanf: floating point formats not matched
Abnormal program termination" ...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |