Jump to content
  • Advertisement
Sign in to follow this  
TEUTON

printf problem

This topic is 4501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What does this statement means...I have never seen such a way of using printf and it's even working fine in VC6.0.
   printf("%d"+2,123);

if I enter 6 instead of 2 I start getting ftbuf.c what is this? For larger numbers I don't get any output. I have no idea what is going around.

Share this post


Link to post
Share on other sites
Advertisement
Try this:
printf("%s","abcdefg"+2);
you will get:
"cdefg"

so "%d"+2 means "" and printf("%d"+2,123) is equal to printf("",123) and the output will be nothing!

"blah blah blah..." is a pointer to the string (a const char* I think) so "blah blah blah..."+n is a pointer to the n-th character of the string.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave
Well you learn something every day don't you.

Dave


Yes...that's right.

Share this post


Link to post
Share on other sites
Character literals all get put into the same section. You can end up with pieces of an entierly different string, something from another section entirely (hate to see what happens when you try to print a jump table as a string), or if you're really unlucky, hit an address where there is no page mapped and pagefault.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!