// convert a string read from stdin to an int // using the atoi function from the standard C library // note no error checking // Andrew Taylor - andrewt@unsw.edu.au // 24/4/13 #include #include #define MAX_LINE 4096 int main(int argc, char *argv[]) { char line[MAX_LINE]; int n; printf("Enter a number: "); fgets(line, MAX_LINE, stdin); n = atoi(line); printf("You entered %d\n", n); return 0; }