How do i put a function inside another function? Im getting confused with the function definition. Plz help??

You have to write two different functions, then in one of them you can call the other, like this

int foo()
{
    return 5;
}

int main()
{
    int x = foo();
}

so then does foo() just start running? how do i get it to Run?

int foo()
{
    return 5;
}

int main()
{
    int x = foo();
}

foo() doesn't just run -- when main() calls foo() the program's execution path will jump to the beginning of foo() and execute all the code in that function then return back to where it left off in main().

so what if i wanna put a function inside foo?

As long as it is declared before it is called and is defined somewhere the compiler/linker can find it, go ahead.

so what if i wanna put a function inside foo?

Not possible. C and C++ do now all you to nest functions (put one function inside the other).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.