delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/06/10:42:51

Date: Mon, 6 Dec 1999 10:20:13 -0500 (EST)
From: Daniel Reed <djr AT narnia DOT n DOT ml DOT org>
Sender: n AT celery DOT n DOT ml DOT org
To: djgpp AT delorie DOT com
Subject: Re: Whatever the input, the output is always 0
In-Reply-To: <82gbc8$gq0$1@imsp026.netvigator.com>
Message-ID: <Pine.LNX.4.21.9912061014210.14079-100000@celery.n.ml.org>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 6 Dec 1999, Jason Yip wrote:
) whatever I input, say 4.0 5.0, the output is always =0 . why??
) pls tell me. thx..
scanf() puts values into the memory pointed to by the arguments you give it,
and in your code it's trying to put the values into the memory locations
pointed to by your uninitialized a and b variables (ie, it's treating a and
b as pointers). What you really want is to pass pointers *to* a and b to
scanf.

) main ()
) {double a,b,s;
) printf("Enter the sides of the triangle: ");
) scanf("%lf%lf",a,b);
scanf("%lf%lf, &a, &b);

-- 
Daniel Reed <n AT ml DOT org>
Misspelled? Impossible. My modem is error correcting!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019