There are built-in functions like atoi, atof, atol and so long.
By using this function you don't need to care of restictions: the given string will be converted or you get zero back!
Take a look at e.g. atoi:
int atoi (const char * str);
Convert string to integer
Parses the C-string str interpreting its content as an integral number, which is returned as a value of type int.
#include <stdio.h> /* printf, fgets */
#include <stdlib.h> /* atoi */
int main ()
printf ("Enter a number: ");
fgets (buffer, 256, stdin);
i = atoi (buffer);
printf ("The value entered is %d. Its double is %d.\n",i,i*2);