Thats really odd, i've tried re-writing it into a single function which i've posted below and I still get the same problem.
im using Dev C++ to compile in windows. Cheers for looking at it.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int stringToInt(char s[])
{
int i = 0;
int power = strlen(s) - 1;
int value = 0, curNo = 0, sign = 0;
/* test for negativity */
if(s[i] == '-')
{
sign = 1;
i++;
power--;
}
while(s[i] != '\0')
{
curNo = s[i] - 48;
if(curNo > 9 || curNo < 0)
{
printf("error");
exit(1);
}
value = (value + (curNo * pow(10,power)));
i++;
power--;
}
if(sign == 1)
{
value = -(value);
}
return value;
}
int main(int argc, char* argv[])
{
printf("%d", stringToInt(argv[1]));
return 0;
}