Alright, so I have my own forum up (SMF) and I added a shop mod to try to get my users a little more active. The shop has been pretty inactive at this point so I decided to write a program that would earn my members shop credits. The program starts off by prompting users to input their forum ID number. All is fine when you put in a number, but I want to prevent bugs when someone feels they need to try and put characters in instead.
Here is the source pertaining to the problem.
When I put in an integer, I get the "else" statement. When I put in any characters, it just repeats this endless loop of going to id(); and then the else statement. How can I fix this?Code:#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <ctype.h>
#include "Declare.h"
using namespace std;
// Main
int getid;
char input[100];
int input1;
// Game 1
int j;
int a = 2000;
int k = (((rand() % 20) + rand() % 10) * getid);
int shop = 10000;
int wep = getid * 5;
string start("START http://www.chatshack.us/forum/index.php?action=pm;sa=send;u=1");
string open("START k.ccs");
string delfile("if exist k.css del k.ccs");
// End Declarations
int main() {
SetConsoleTitle("Chatshack Public Entertainment First Release!");
deletefile();
id();
cout << "Welcome to the first chatshack.us community game!\nHere you will be playing our game to earn forum shop cash.\n";
cout << "Lets get started!\n\n";
cout << "Make a selection:\n\n";
cout << " 1 - CCS History\n 2 - Guess the Password\n 3 - Game 2\n 4 - Game 3\n 5 -\n";
cout << " 6 - \n 7 - \n 8 - \n 9 - \n10 - Load Chief's Chat Shack\n" << endl;
cout << "Selection: ";
cin >> input1;
switch ( input1 ) {
case 1:
beta();
break;
case 2:
game1();
break;
case 3:
game2();
break;
case 4:
game3();
break;
case 5:
beta();
break;
case 6:
beta();
break;
case 7:
beta();
break;
case 10:
runccs();
break;
default:
system("cls");
cout << "Error!" << endl;
cin.get();
Sleep(1000);
system("cls");
main();
break;
}
return 0;
}
// Start Misc Voids
void id() {
system("cls");
cout << "What is your forum ID?\n\nID: ";
cin >> getid;
if (isdigit(getid)) {
cout << "\nID saved!" << endl;
Sleep(1000);
system("cls");
} else {
system("cls");
cout << "Error, please try again" << endl;
Sleep(1000);
main();
}
cout << "Testing" << endl;
}