Thread: what's wrong with this? SOS

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    17

    Exclamation what's wrong with this? SOS

    Code:
    #include <stdio.h>
    
    
    struct {
    	void (*x)( char *);	
    }X;
    void init()
    {
    	void p( char *s)
    	{
    		puts( s);
    	}
    	X.x = p;
    }
    
    
    void ext()
    {
    	X.x("Wener");
    }
    int main(int argc, char *argv[])
    {
    	init();
    	X.x("Wener");
    	ext();
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    17
    online waiting

  3. #3
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    There are no nested functions in C.
    Kurt

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    17
    in Cfree, i can not run over, but in mingw and cygwin it's no problem. so why?

  5. #5
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    GCC supports nested functions in C, as a language extension.
    Kurt
    EDIT: Just looked it up. c-free seems to be an ide that uses gcc as the compiler by default. if so then you propably use different optiions ( gcc -std=... )
    Last edited by ZuK; 04-19-2012 at 07:41 AM.

  6. #6
    Registered User
    Join Date
    Dec 2011
    Posts
    17
    ok, i was wrong, even it pass the compile

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    17
    thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-14-2011, 06:35 PM
  2. wrong wrong with my xor function?
    By Anddos in forum C++ Programming
    Replies: 5
    Last Post: 04-26-2009, 01:38 PM
  3. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-28-2005, 12:48 AM
  4. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  5. where have i gone wrong?
    By sworc66 in forum C Programming
    Replies: 3
    Last Post: 08-13-2002, 08:34 AM

Tags for this Thread