summaryrefslogtreecommitdiffstats
path: root/Tests/Tutorial/Step6/tutorial.cxx
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2019-01-20 16:28:39 (GMT)
committerBetsy McPhail <betsy.mcphail@kitware.com>2019-01-27 21:03:00 (GMT)
commitf2ddedfa5802c8aece994bb643b5139212d87777 (patch)
treef1dc800bf22bbfccbde4e1deb0c235986731e2cd /Tests/Tutorial/Step6/tutorial.cxx
parent438651506a5417be70e71f54f4ed7add0c2604d3 (diff)
downloadCMake-f2ddedfa5802c8aece994bb643b5139212d87777.zip
CMake-f2ddedfa5802c8aece994bb643b5139212d87777.tar.gz
CMake-f2ddedfa5802c8aece994bb643b5139212d87777.tar.bz2
Tests: Update CMake tutorial
Latest material from data.kitware.com -> Collections -> Courses -> CMake.
Diffstat (limited to 'Tests/Tutorial/Step6/tutorial.cxx')
-rw-r--r--Tests/Tutorial/Step6/tutorial.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx
index 37f6ac4..1d5742d 100644
--- a/Tests/Tutorial/Step6/tutorial.cxx
+++ b/Tests/Tutorial/Step6/tutorial.cxx
@@ -1,8 +1,9 @@
// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
#ifdef USE_MYMATH
# include "MathFunctions.h"
@@ -11,23 +12,21 @@
int main(int argc, char* argv[])
{
if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MAJOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
return 1;
}
- double inputValue = atof(argv[1]);
- double outputValue = 0;
+ double inputValue = std::stod(argv[1]);
- if (inputValue >= 0) {
#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
+ double outputValue = mysqrt(inputValue);
#else
- outputValue = sqrt(inputValue);
+ double outputValue = sqrt(inputValue);
#endif
- }
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
return 0;
}