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.

Recommended Answers

All 6 Replies

Yes, you can, it is called recursion. Look it up on net

>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';

int main() {
   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 -

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...

ok thanks for ur help

3 answers at pretty much the same time ^.^ thats a record for me.

Be a part of the DaniWeb community

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