can you call a function inside that same function so that it goes to the beginning of that code to execute it. So even though ur already in the prompt function can u still call it again from withing the code inside the prompt function. Thanks in advance.

>can you call a function inside that same function
If I understood that correctly then..

If you call a function while your already in it, you have recursion. Take this as an example.

#include <iostream>
using namespace std;

void CountDown(int number) {
   if (number != 0) {
      cout << number << '\n';
      CountDown(--number);
   }
}

int main() {
   CountDown(100);
   cin.ignore();
   return 0;
}

This will keep calling the CountDown function, subtracting 1 from that number, and then displaying it until number reaches 0, when that happends, it will stop calling CountDown and it will break out the loop. Here is a tutorial on recursion - http://www.cprogramming.com/tutorial/lesson16.html

Hope this is what your looking for ;)

Of course, you can do that. It's called recursion. The only problem is to break recursive call chain in the proper moment. In other words you must prevent f() call which calling f() which calling f() again and so on...

This article has been dead for over six months. Start a new discussion instead.