Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 22-08-2007, 02:28 PM   #1 (permalink)
Hey here is the aks
 
arunks's Avatar
 
Join Date: Jan 2006
Location: punjab
Posts: 805
Default plz remove error in my c program


i wrote a program which is given below

Code:
#include<stdio.h>
#include<conio.h>
struct employee
{
char name[5];
char deptt[5];
int idcode;
float s;
};

void main()
{
struct employee emp[2];
int i,j;
clrscr();
for(i=0;i<2;i++)
{
gets(emp[i].name);
gets(emp[i].deptt);
scanf("%d",&emp[i].idcode);
scanf("%f",&emp[i].s);
}
getch();
}

but when i run it after asking three values name then deptt then idcode then it gives the following error

Code:
scanf: floating point formats not linked
abnormal program termination
plz see why this is so.. and make my program error free

if u want then run it in C and see urself when error comes

PROGRAM2 : another program i have writeen is also not showing ouput as expected..

Code:
#include <stdio.h>
#include <conio.h>

struct test ** display(struct test*);  //function prototype
//structure delaration starts here
struct test
{
int cnt;
int chr;
};

void main(void)
{
struct test tst,**tt;
clrscr();
tt=display(&tst);

printf("cnt: %d \n ", (*tt)->cnt);
printf("chr: %c \n ", (*tt)->chr);

getch();


}

struct test ** display(struct test *ptr)
{
ptr->cnt = 1;
ptr->chr = 'a';
return(&ptr);
}


it doesnt print value of chr.
why is it so and plz correct it
__________________
yours truly
arun
The aks!!

have a nice day

Last edited by arunks; 22-08-2007 at 02:28 PM. Reason: Automerged Doublepost
arunks is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 22-08-2007, 02:34 PM   #2 (permalink)
Old Stock in New Bottle!!
 
Digit_Dragon's Avatar
 
Join Date: Jan 2007
Posts: 62
Default Re: plz remove error in my c program

Hi Dude,
For the first program there is no error......you enter name and deptt .....only problem is in the output the values are not getting assigned properly. Because of your gets and scanf.

Whenever you program make it user friendly give some statements like Enter the name, Enter the Dept, then scanf it to required variable.

Anyway when compiled and run the program has no error.
Digit_Dragon is offline  
Old 22-08-2007, 08:19 PM   #3 (permalink)
Hey here is the aks
 
arunks's Avatar
 
Join Date: Jan 2006
Location: punjab
Posts: 805
Default Re: plz remove error in my c program

ya program has error when u enter first three values ..first u enter a name then enter a deptt then enter a integer idcode then error will come regarding floating linking something and no problem is coming with using gets and scanf...


as if i chage idcode variable to int type instead of float then it works fine..
the program gives error when it is of float type..

Anybody plz help.......
__________________
yours truly
arun
The aks!!

have a nice day
arunks is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove this error??? magnet QnA (read only) 17 08-01-2007 09:54 AM
remove startup program anu0512 Software Q&A 5 08-11-2006 02:33 PM
Disable add/remove program linardni QnA (read only) 6 06-11-2006 03:43 PM
Java Program Error! nitish_mythology QnA (read only) 7 06-01-2006 04:37 PM

 
Latest Threads
- by Tenida
- by Charan
- by abhidev

Advertisement




All times are GMT +5.5. The time now is 10:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2