Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion tricky question on strings!! please comment
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kenneth Brody  
View profile  
 More options Aug 26 2004, 3:41 pm
Newsgroups: comp.lang.c.moderated
From: Kenneth Brody <kenbrody+c...@spamcop.net>
Date: 26 Aug 2004 19:41:26 GMT
Local: Thurs, Aug 26 2004 3:41 pm
Subject: Re: tricky question on strings!! please comment

Rohit Dhamija wrote:

> Couldn't come up with the logic of the below program
> What will be the output of the following program :
>  int main()
>  {
>    printf("%d"+1,123);
>    return(0);
>  }
> Ans comes out to be 2

Technically, this program produces undefined behavior, as the last thing
output does not end in '\n', so I wouldn't says your compiler is "broken".
But, if that's really what you get, it's probably seriously funky.

The above program is equivalent to:

int main()
 {
   printf("d",123);
   return(0);
 }

On most systems, you would probably end up with a single lower-case "d"
being output.  Others would probably end up with no output at all.

For example, my Unix system shows:

# cc -o foo foo.c
# ./foo
d#

--
+-------------------------+--------------------+--------------------------- --+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody/at\spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+--------------------------- --+
--
comp.lang.c.moderated - moderation address: c...@plethora.net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.