Mega Code Archive

 
Categories / C / String
 

Convert string to long integer

#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; }