summaryrefslogtreecommitdiffstats
path: root/Tests/Tutorial/Step2/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/Step2/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/Step2/tutorial.cxx')
-rw-r--r--Tests/Tutorial/Step2/tutorial.cxx32
1 files changed, 11 insertions, 21 deletions
diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx
index 37f6ac4..75b7d67 100644
--- a/Tests/Tutorial/Step2/tutorial.cxx
+++ b/Tests/Tutorial/Step2/tutorial.cxx
@@ -1,33 +1,23 @@
// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cmath>
+#include <iostream>
+#include <string>
-#ifdef USE_MYMATH
-# include "MathFunctions.h"
-#endif
+#include "TutorialConfig.h"
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;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
+ double inputValue = std::stod(argv[1]);
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
+ double outputValue = sqrt(inputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
return 0;
}