#include #ifndef NULL #define NULL (void *) 0 #endif #define LINE_LEN 64 int atoigt(char line[]) { int val = 0; int ptr = 0; while (line[ptr] >= '0' && line[ptr] <='9' && line[ptr]!='\0') { val = val * 10 + (line[ptr] - '0'); ptr++; } return val; } int main(int argc, char const *argv[]) { char line[LINE_LEN]; printf("Enter an integer: "); while (NULL != fgets(line, LINE_LEN, stdin)) { printf("The original string:<%s> Print the string as in int:<%d> the integer:%d\n", line, line, atoigt(line)); printf("\nEnter an integer: "); } return 0; }