Archived

This topic is now archived and is closed to further replies.

pointer_to_main

Trivial facts

Recommended Posts

Did you know you can use main as a recursive function ? void (*pMain)() = main; //great for stack overflows....lol Q: What is the smallest data type that can be used? A: ONE single bit (read up on bit field structs ) Q: How would you prototype this? A function that takes a pointer to a pointer to an int and returns a pointer to an array of 5 pointers to functions that take an array of const chars and return an int. *forgot to mention this in first post ANSWER IS BELOW ( dont want to spoil any ones attempt) a: int (*(*foo(int **))[5])(const char []); [edited by - pointer_to_main on November 18, 2003 6:07:47 AM]

Share this post


Link to post
Share on other sites
Actually, you're officially not allowed to use main like that, although a lot of compilers support it; see section 3.6.1.3 of the C++ standard.. It's pretty much useless anyway.

[edited by - sneftel on November 18, 2003 4:12:00 PM]

Share this post


Link to post
Share on other sites