-
Help with casting
I am writting a validation program.
this program receives a string from another program. this string contains a number like 123.
what my program has to do is convert this string into a short and validate it. i have to make sure the number is between 1-300.
after i validated it i have to pass it to another function.
does anyone know how to convert the string into a short???
thanks
-
use atoi... converts strings to integers...
-
You can use atoi() to return an int. To turn that int into a short you can do this....
char array[5]="1234";
int num=atoi(array);
short snum=num & 0xffff;