Thread: need explanation for given pgm

  1. #1
    Registered User
    Join Date
    Sep 2010

    Lightbulb need explanation for given pgm

    int main()
    	int i=10;
    	void f(int,int,int);
    	return 0;
    void f(int x, int y, int z)
    	printf("%d %d %d",x,y,z);
    Hi see above code. It prints the result as 12 11 10. How it is? Can you explain?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    It has undefined behaviour. Read the various items in this FAQ.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked Lists
    By Bleu_Cheese in forum C++ Programming
    Replies: 13
    Last Post: 12-21-2007, 09:17 PM
  2. How to write image data to binary PGM file format(P5)?
    By tommy_chai in forum C Programming
    Replies: 6
    Last Post: 11-03-2007, 10:52 PM
  3. printf function explanation
    By vice in forum C Programming
    Replies: 3
    Last Post: 09-21-2005, 08:35 PM
  4. basic linked list declaration..need explanation
    By aspand in forum C Programming
    Replies: 3
    Last Post: 06-07-2002, 05:55 PM
  5. quick question about C Dos text menu pgm i was doing
    By Shadow in forum C Programming
    Replies: 2
    Last Post: 09-16-2001, 10:26 AM