summaryrefslogtreecommitdiffstats
path: root/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-11-10 15:51:25 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-11-10 15:51:25 (GMT)
commit6f5a53618a73b1d0437c7915a8aa0ed2b04d6eda (patch)
treea2873a3f61c47e99700eb879403faa1581e89cec /Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
parent699a97a504f0a56858c91399954fb368a37048b7 (diff)
downloadCMake-6f5a53618a73b1d0437c7915a8aa0ed2b04d6eda.zip
CMake-6f5a53618a73b1d0437c7915a8aa0ed2b04d6eda.tar.gz
CMake-6f5a53618a73b1d0437c7915a8aa0ed2b04d6eda.tar.bz2
ENH: step 5
Diffstat (limited to 'Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx')
-rw-r--r--Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
new file mode 100644
index 0000000..23fa7d4
--- /dev/null
+++ b/Tests/Tutorial/Step5/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 tabel fo 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;
+}