1 - I have this code (I gave a summary, type -1, and then 'n' to exit the loop and the error occurred):
#include <iostream>
#include <cstdlib>
#include <cstdio>
#undef max
using namespace std;
int* cont = new int(0);
//-----------------------------------------// MAIN // -----------------------------------//
void main(){
char* n = new char('s');
while (*n == 's' || *n == 'S'){
int* dinheiro = new int(500);
while (*dinheiro >= 1){
printf("Quanto Deseja Apostar ? ");
scanf("%d%*c", &*dinheiro);
printf("\nTentar Novamente (s-n) ? ");
cin >> n;
cin.ignore(numeric_limits<int>::max(), '\n');
system("cls");
}
delete dinheiro;
}
delete n;
}
And in that part:
printf("Tentar Novamente (s-n) ? ");
cin >> *n;
cin.ignore(numeric_limits<int>::max(), '\n');
system("cls");
If the user does not type 's' to go back in the loop he gives this error:
Note: Removing the delete
program works correctly.