Skip to content

Instantly share code, notes, and snippets.

@sumeet
Created June 28, 2022 02:46
Show Gist options
  • Save sumeet/260268498104089dc600345932b2e840 to your computer and use it in GitHub Desktop.
Save sumeet/260268498104089dc600345932b2e840 to your computer and use it in GitHub Desktop.

Command line adder

Adds together all numbers separated by newlines from input. If an empty line is given, doesn't add anything to the total sum (i.e., it adds 0).

Terminate the program by either sending EOF (Ctrl-D), or with the keyword END. Upon termination, the program will print out the whole sum.

Example:

$ cargo run
1
2018
2

3
-1
END
Total: 2023
$ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment