Code: Select all
#include <iostream>
#include <string.h>
using namespace std;
bool isInt(const char *c)
{
int i = -1;
if(strlen(c) > 0)
{
for(i;i<(strlen(c));i++)
{
if(!(isdigit(c[i]))) { return false; }
}
return true;
}
return false;
}
int main(void)
{
const char *blah = "1";
if(isInt(blah))
{
cout << "Yep" << endl;
}
if(!isInt(blah))
{
cout << "Nope" << endl;
}
return 0;
}
I'm trying to make a basic language for 2d games with allegro, then I will build a GUI for it like GameMaker, but using allegro for the gaming engine.
I will probably have prebuilt stuff in it, such as prebuilt gravity functions, and collision functions. If I can just get past this string manipulation. I'm sure this is something simple, probably so simple I'm just overlooking it. Any help would be great.
Thanks...