Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Structure of Array within the C and C++ forums, part of the Software Development category; Hi all, I have written following program which has a array of structures. But it is reading only integer & char values. As soon as it comes to float, it ...
|
|||||||
|
|||
|
Hi all,
I have written following program which has a array of structures. But it is reading only integer & char values. As soon as it comes to float, it is not reading & coming out of the program. Can anyone assist me to find the mistake. #include<stdio.h> #include<conio.h> #include<string.h> void main() { struct student { int id; char usn[11]; float y; }; struct student s1[10]; int i,n; clrscr(); printf("enter value for n=>"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter id=>"); scanf("%d",&s1[i].id); printf("enter usn=>"); fflush(stdin); gets(s1[i].usn); printf("enter float number=>"); scanf("%f",&s1[i].y); } for(i=0;i<n;i++) { printf("s1===> %10d%20s%10.2f\n",s1[i].id,s1[i].usn,s1[i].y); } getch(); } Thanks & Regards, Abhijit |
| Sponsored Links |
|
|||
|
Re: Structure of Array
Hello....
you have to define a function linkfloat() beacuse in majority of compiler floating point format are not linked.....linkfloat() function forces linking of floating_point emultor into an application....... The given below source code will work.......... ******************************************** #include<stdio.h> #include<conio.h> #include<string.h> void main() { struct student { int id; char usn[11]; float y; }; struct student s1[10]; int i,n; clrscr(); printf("enter value for n=>"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter id=>"); scanf("%d",&s1[i].id); printf("enter usn=>"); fflush(stdin); gets(s1[i].usn); printf("enter float number=>"); scanf("%f",&s1[i].y); } for(i=0;i<n;i++) { printf("s1===> %10d%20s%10.2f\n",s1[i].id,s1[i].usn,s1[i].y); } getch(); } void linkfloat(){ float a=0,*b; b=&a; a=*b; } ********************************************************* Sumit Kumar sumitsolution@gmail.com Karunya University Last edited by sumitsolution; 10-08-2009 at 03:47 AM. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Structure Padding in C | sk_seeker | C and C++ | 5 | 11-10-2008 12:08 PM |
| Database structure of 10g | stephen george | Oracle | 1 | 01-16-2008 08:16 AM |
| structure and class | jinendrashankar | C and C++ | 2 | 12-23-2007 05:46 AM |
| convert one dimansional array to two dimansional array | Geek_Guest | C and C++ | 6 | 12-22-2007 04:17 AM |
| static array or dynamic array? | rpgubba | C and C++ | 6 | 12-22-2007 04:03 AM |