TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: John Poltorak
date: 1995-03-23 10:42:26
subject: scanf

Wednesday March 22 1995, John Poltorak writes to All:

 JP> #include 

 JP> main()
 JP> {
 JP>         int len, width;

 JP>         printf("Enter length: ");
 JP>         scanf("%d", &len);
 JP>         printf("Enter width: ");
 JP>         scanf("%d", &width);

 JP>         printf("area is %d", len * width);
 JP> }


 JP> This is supposed to prompt the user for two values and compute the result.

 JP> When I run this program, I don't get any prompts, before entering any
 JP> values. Is this just a quirk of using an OS/2 compiler, or is Mr. Schildt
 JP> in error here?

 JP> I'm using ICC from C Set/2 v1.0 and this is what the output looks like:-

 JP> [F:\dev\c]ex3
 JP> 12
 JP> 15
 JP> Enter length: Enter width: area is 180
 JP> [F:\dev\c]

Having just installed emx+gcc, I now get the expected results, viz:

[F:\dev\c]ex3
Enter length: 12
Enter width: 15
area is 180
[F:\dev\c]

I am simply stunned to find ICC acting in such an erroneous way with
something so trivial. I also got unexpected results when displaying numbers
of type 'double'. All this makes me rather hesitant about learning 'C'
using the C Set/2 compiler. I guess I'll move over to GCC for the time
being.

John

--- GoldED/2 2.50.Beta4+
* Origin: (2:250/313)
SEEN-BY: 105/42 620/243 624/300 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 250/313 440/4 141/209 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.