Convert string to long integer: how to use strtol
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char str[256];
char *p;
long l;
printf ("Enter an long value: ");
gets (str);
l = strtol (str, &p, 0);
printf ("Value entered: %ld. Its double: %ld\n", l, l * 2);
return 0;
}
Related examples in the same category