I worked my butt out (to improve it) and I came up with this :

The function returns 0 for no errors and 1 if there are errorsPHP Code:

`int checknumber(char array[20])`

{

int i;

int minuscount = 0;

int pointcount = 0;

int bad = 0;

for (i=0; array[i]; i++)

{

if ( array[i] == 45)

{

minuscount++;

}

if ( array[i] == 46)

{

pointcount++;

}

if( array[0] == NULL || array[i] < 45 || array[i] == 47 || array[i] > 57 )

{

bad = 1;

}

if(i>0 && array[i] == 45)

{

bad = 1;

}

}

if (minuscount > 1 || pointcount > 1)

{

bad = 1;

}

return bad;

}

LIMITATIONS :

1) . is valid

2) -. is valid

3) x. is valid (where x is a number)

4) array can't have more than 20 elements. increase this if you want.

Also, if you're using cin, ' ' (space) will give strange problems.

I hope this will be of some use to you.