//getInput.h, made by TheUberFail
#include <iostream>
#include <string.h>
#include <windows.h>
#include <conio.h>
using namespace std;
string getInputString(bool filterNum,bool filterChar,bool filterSym,bool filterSpace,bool rejectString,string defaultStr)
{
string Oinput ="";
string Ainput ="";
short counter = 0;
getline(cin,Oinput);
for(short index = 0; index < Oinput.length(); index++)
{
if(filterNum)
{
if(Oinput[index]<='9'&&Oinput[index]>='1'
{
if(rejectString)
{
return defaultStr;
}
continue;
}
}
if(filterSym)
{
if(!(Oinput[index]<='9'&&Oinput[index]>='1'&&!(Oinput[index]<='Z'&&Oinput[index]>='A'&&!(Oinput[index]<='z'&&Oinput[index]>='a'&&Oinput[index]!=' '
{
if(rejectString)
{
return defaultStr;
}
continue;
}
}
if(filterSym)
{
if((Oinput[index]<='Z'&&Oinput[index]>='A'||(Oinput[index]<='z'&&Oinput[index]>='a')
{
if(rejectString)
{
return defaultStr;
}
continue;
}
}
if(filterSpace)
{
if(Oinput[index]==' '
{
if(rejectString)
{
return defaultStr;
}
continue;
}
}
Ainput += Oinput [index];
continue;
}
return Ainput;
}
int getNumber()
{
string ILine = "";
char input_stream;
short charCounter = 0;
int number = 0;
int power = 0;
for(;
{
if(kbhit())
{
input_stream = getch();
if(charCounter!=0)
{
if(input_stream == '0'
{
ILine += input_stream;
charCounter++;
cout<<input_stream;
}
}
if(input_stream >= '1' && input_stream <= '9'
{
ILine += input_stream;
charCounter++;
cout<<input_stream;
}
if(input_stream ==
{
if(charCounter!=0)
{
cout<<input_stream<<" "<<input_stream;
ILine.erase(ILine.end()-1,ILine.end());
charCounter--;
}
}
if(input_stream==13)
{
break;
}
}
Sleep(50);
}
for(short count = 0; count < ILine.length(); count++)
{
power =1;
//if(count != 0)
{
for(short sCount = 0; sCount <= count; sCount++)
{
power *= 10;
}
}
number += ((((int)ILine[ILine.length()-(count)-1])-4*power);
}
number /= 10;
return number;
}
void doStringExample()
{
system("CLS");
string tempStr;
cout<<"\n\tEnter a number: ";
// Dont filter number Filter alphabet Filter symbols Filter spaces Reject bad input If rejected, this is default
tempStr = getInputString(0, 1, 1, 1, 0, "");
cout<<"\n\tYou entered: "<<tempStr;
cout<<"\n\tEnter a sentance with no numbers\n\n\tSentance: ";
// filter number Dont Filter alphabet Dont Filter symbols Dont Filter spaces Reject bad input If rejected, this is default
tempStr = getInputString(1, 0, 0, 0, 1, "You entered numbers!");
cout<<"\n\tYou entered: "<<tempStr;
system("PAUSE");
system("CLS");
return;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.