From: Senthil. [mailto:[EMAIL PROTECTED]
>Hi friends plz help me to solve this ....
>how the below program works for char and int without being
>declared with types inside the structure but it does not work
>for float (ie %f program terminates!!)
Because you are abusing the C language, and using old features that have
been removed (or in your compilers case, depreciated) - the one I think
you're abusing is implied int:
>also this is not allowed outside structure why ??
Implied int is also allowed for function definitions/declarations.
>#include<stdio.h>
>#include<conio.h>
Non-standard header. If you're using non-standard headers/functions then
please say which compiler you're using. Better still try to avoid them
completely since not everyone will be using 'your compiler' and if they
try to compile your programs, they will fail and the effort to 'correct'
your code will be one of:
a) too much effort so they don't bother
b) introduce further errors
c) remove functionality and/or the bugs you're asking about.
>struct a
>{
> s;
> r;
Presumably implied int. Turn up the warnings on your compiler, and turn
on any ANSI/ISO compatability if possible. Regardless of this you should
always fully specify the type of variables and functions.
>}b;
>void main()
main returns int, not float, class foo or void.
>{
> clrscr();
Non-standard function.
> b.s= '1' ;
Presuming your compiler has declared s to be an int, this will 'work'.
> b.r=2;
As will this. Float assignments will get truncated to integer before
being assigned.
> printf("%c",b.s);
> printf("%d",b.r);
Since you have no linefeeds before the end of the program, it is
permitted for this program to produce no output whatsoever. In practise
this is unlikely, but best to be on the safe side.
> getch();
Non-standard function.
>}
--
PJH
"During my service in the United States Congress, I took the initiative
in creating the Internet."
- Al Gore
Alderley plc, Arnolds Field Estate, The Downs, Wickwar, Gloucestershire, GL12
8JD, UK
Tel: +44(0)1454 294556 Fax: +44 (0)1454 299272
Website : www.alderley.com Sales : [EMAIL PROTECTED] Service : [EMAIL
PROTECTED]
This email and its contents are confidential and are solely for the use of the
intended recipient. If you are not the original recipient you have received it
in error and any use, dissemination, forwarding, printing or copying of this
email is strictly prohibited. Should you receive this email in error please
immediately notify [EMAIL PROTECTED]
This email has been scanned for viruses, however you should always scan emails
with your own systems prior to opening.
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~->
To unsubscribe : [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4905
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/