summaryrefslogtreecommitdiffstats
path: root/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2007-11-08 15:38:26 (GMT)
committerDavid Cole <david.cole@kitware.com>2007-11-08 15:38:26 (GMT)
commit4e752dee910d3901a438d97aedf49357a8cb5628 (patch)
tree3393d691a3e67c13610b9252e2f967d4433f95a6 /Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
parente615e1416cc5139082593c07db99ead11c6d5d46 (diff)
downloadCMake-4e752dee910d3901a438d97aedf49357a8cb5628.zip
CMake-4e752dee910d3901a438d97aedf49357a8cb5628.tar.gz
CMake-4e752dee910d3901a438d97aedf49357a8cb5628.tar.bz2
ENH: Add new Tutorial steps. Diff between Step5 and Step6 shows how to add a cpack driven installer to your project. Diff between Step6 and Step7 shows how to add ctest dashboard scripting capability.
Diffstat (limited to 'Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx')
-rw-r--r--Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
new file mode 100644
index 0000000..6a2be3a
--- /dev/null
+++ b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
@@ -0,0 +1,35 @@
+// A simple program that builds a sqrt table
+#include <stdio.h>
+#include <math.h>
+
+int main (int argc, char *argv[])
+{
+ int i;
+ double result;
+
+ // make sure we have enough arguments
+ if (argc < 2)
+ {
+ return 1;
+ }
+
+ // open the output file
+ FILE *fout = fopen(argv[1],"w");
+ if (!fout)
+ {
+ return 1;
+ }
+
+ // crate a source file with a table of square roots
+ fprintf(fout,"double sqrtTable[] = {\n");
+ for (i = 0; i < 10; ++i)
+ {
+ result = sqrt(static_cast<double>(i));
+ fprintf(fout,"%g,\n",result);
+ }
+
+ // close the table with a zero
+ fprintf(fout,"0};\n");
+ fclose(fout);
+ return 0;
+}