Information
The numbers in RED are typed by the user.Enter an integer (1 to 2,147,483,647 without commas): 1776 The number of digits in 1776 is 4. Enter an integer (1 to 2,147,483,647 without commas): 8 The number of digits in 8 is 1. Enter an integer (1 to 2,147,483,647 without commas): 1357902468 The number of digits in 1357902468 is 10.
The name of the file should be numdigits.c and the command to compile it will look like this:
output-numdigits.txt This output was generated by running the program 9 times, using each of these numbers:gcc -Werror -Wall -Wextra -ansi -pedantic numdigits.c -o numdigits
1 42 555 1729 65535 142857 8675309 63288349 999999937 2147483647
Notes
On subsequent redirects, use two greater-than symbols with no space between them (>>).numdigits > myoutput.txt
This will append to the existing file, rather than overwrite it. Of course, you won't see any prompt because that, too, is being redirected to the file.numdigits >> myoutput.txt
For students that want to practice their C-fu