Posted by Eian on 1999-09-12
instead of:
if(diag == "circle")
you should use:
if(strcmp(diag,"circle") == 0)
or, if you want it to be case-insensitive use:
if(strcasecmp(diag,"circle") == 0)
Enjoy,
Eian
On Sun, 12 Sep 1999 rominirani@xxxxxx.xxx wrote:
> #include <stdio.h>
> #include <dos.h>
> #include <string.h>
> main()
> {
>
> float l,b,r,area;
> char diag[10];
>
> printf("Enter whether circle or rectangle: ");
> scanf("%s",&diag);
>
> if (diag == "circle")
> {
> printf("Enter radius : ");
> scanf("%d",&r);
> area = 3.14 * r * r;
> }
> else
> {
> printf("Enter length and breadth : ");
> scanf("%d %d",&l,&b);
> area = l * b;
> }
> printf("Area of %s is := %.2f\n",diag,area);
> sleep(10);
> }
>
> guys i'm having a problem with the entered value i.e circle
> when i enter circle it directly gives me "area of circle is := 0.0"
> what do u have to do compare the char input?
>
>
>
>
> ________________________________________________________________
> Get FREE voicemail, fax and email at http://voicemail.excite.com
> Talk online at http://voicechat.excite.com
> >
>
/-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\
| -=< THIATS >=- |
| This is a THIATS signature. |
| |
| GNU eat your heart out! |
| |
\-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/
Previous post | Next post | Timeline | Home