TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: David Breeding 72330,2051 (X)
from: Bob van der Poel 76510,2203
date: 1995-03-26 22:10:38
subject: #20865-#scanf() question

#: 20869 S3/Languages
    26-Mar-95  22:10:38
Sb: #20865-#scanf() question
Fm: Bob van der Poel 76510,2203
To: David Breeding 72330,2051 (X)

I must admit that not only do I not advocate using scanf()...I've never used it
either. So, I decided to test a bit...interesting.

 main()
 {
        int v1, v2;

        scanf("%d%d", &v1, &v2);

        printf("V1=%d V2=%d\n", v1, v2);
 }

With this program I can enter either:

 123 456

or

 123
 456

and get proper results. Matter of fact, I can even put in extra spaces and all
is okay. I figured that I would have to include a \n in the control string to
such the CR input from the keyboard...but that really doesn't work at all.
Hmmm, maybe I know why I don't use this now.

There are 2 Replies.

SOURCE: compuserve via textfiles.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™.