need explanation for given pgm

This is a discussion on need explanation for given pgm within the C Programming forums, part of the General Programming Boards category; Code: int main() { int i=10; void f(int,int,int); f(i++,i++,i++); return 0; } void f(int x, int y, int z) { ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    32

    Lightbulb need explanation for given pgm

    Code:
    int main()
    {
    	int i=10;
    	void f(int,int,int);
    	f(i++,i++,i++);
    	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
    Location
    Singapore
    Posts
    21,598
    It has undefined behaviour. Read the various items in this FAQ.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 08: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21