I created the following function:
void imprimir(void){
cout << "Y\n";
imprimir();
}
Trying to learn more about the usefulness of using a recursive function (a function that calls itself).
By including it in my code, this has been left like this:
#include <iostream>
using namespace std;
void imprimir(void){
cout << "Y\n";
imprimir();
}
int main(void){
imprimir();
return 0;
}
As simple as the function is executed and is still running, I have encountered the following problem.
After a few seconds, this error message appeared:
Segmentation fault: 11
Why does this happen? If recursion is a programming concept and C ++ supports recursion, because this error has occurred, if the function does not use pointers or anything out of the ordinary.
It takes about 8 seconds to stop working. Is it necessary to include some waiting time?