Thread: i++ query

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    i dont get wat u mean by an undefined result....wat i am gettin to is that y does my compiler calculate the division in a different way when i directly output it in the printf() func
    In a sense, an undefined result means that the compiler is free to set any result.

    So i++/i++ could be 0, 1, or -1 etc regardless of the value of i.

    so the compiler goes frm right to left doesnt it??
    then y go frm left to right in the printf ()??
    Have you visited the website that Salem linked to?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    Quote Originally Posted by laserlight
    In a sense, an undefined result means that the compiler is free to set any result.

    So i++/i++ could be 0, 1, or -1 etc regardless of the value of i.


    Have you visited the website that Salem linked to?
    i did visit the site....but i dont tink that there is anything relating to this aspect.....correct me if m wrong...i cud have overlooked something....i understood wat u say bout the undefined thing....
    the answer i get to the i=i++/i++ thing is 3....and i tried it on atleast 3 compilers and got the same result.....also,the left and right ting seems to have gotten me confused...please help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple query language
    By afflictedd2 in forum C++ Programming
    Replies: 3
    Last Post: 12-04-2008, 05:29 PM
  2. query problem
    By arian in forum C# Programming
    Replies: 1
    Last Post: 08-18-2008, 01:49 PM
  3. DNS Query
    By Simpsonia in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-24-2006, 12:42 AM
  4. dns query
    By bulldog in forum C Programming
    Replies: 6
    Last Post: 02-24-2004, 10:44 AM
  5. WBEM Query too slow
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 10-08-2001, 05:28 PM