delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/08/27/05:00:21

From: "Kenton W. Mellott" <melken AT co DOT tds DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Simple program. Strange results.
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <HfZ2b.3213$cQ1.755278@kent.svc.tds.net>
Date: Wed, 27 Aug 2003 07:40:23 GMT
NNTP-Posting-Host: 69.21.9.31
X-Complaints-To: abuse AT tds DOT net (TDS.NET Help Desk 1-888-815-5992)
X-Trace: kent.svc.tds.net 1061970023 69.21.9.31 (Wed, 27 Aug 2003 02:40:23 CDT)
NNTP-Posting-Date: Wed, 27 Aug 2003 02:40:23 CDT
Organization: TDS.NET Internet Services www.tds.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

When compiling the following program with gcc (no switches) almost all the
input variable end up displaying strange results.


        #include <stdio.h>

        int scanf(const char *format, ...);

        int main()
        {
                puts("Please enter a string.");
                char buf[100];
                scanf("%s", buf);
                            printf("you just entered: ''%s''.  \n", buf );


                puts("Please enter a floating point number.");
                float x,y;
                scanf("%f", !x);
                            printf("you just entered: '%g'.  \n", !x );


                puts("Please enter 2 floating point numbers and a string.");
                scanf("%f %f %s", !x, !y, buf);
                            printf("you just entered: '%g','%g', '%s'.\n",
!x, !y, buf);


 }


Sincerely,

Gregory D. MELLOTT


- Raw text -


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