correctcppis_even

January 31, 2018 ยท View on GitHub

BranchTravis CICodecov
masterBuild Statuscodecov.io

Correct C++ chapter 'is even'.

Goals

  • First use of std::regex

Prerequisites

Exercise

Write a command-line interface (CLI) program that determines if its argument is an even number.

If there are more arguments supplied, exit the program.

Call to is_evenOutputExit status
./is_evenAny1
./is_even 12345678901234567890true (with newline)0
./is_even 12345678901234567891false (with newline)0
./is_even nonsenseAny1
./is_even 2 1Any1

This is the code you start with:

main(argc, argv)
{
  //Your code here
}
  • You cannot use std::stoi, as it will not convert 12345678901234567890 to integer
  • Instead, you should use std::regex
  • An even number is a regular expression of one or more digits, that may or may not start with a minus
  • [none]