Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Tests / Tutorial / Step6 / MathFunctions / MakeTable.cxx
blob6a2be3a14f406185e1b6fb7b4244e3947f1038cb
1 // A simple program that builds a sqrt table
2 #include <stdio.h>
3 #include <math.h>
5 int main (int argc, char *argv[])
7 int i;
8 double result;
10 // make sure we have enough arguments
11 if (argc < 2)
13 return 1;
16 // open the output file
17 FILE *fout = fopen(argv[1],"w");
18 if (!fout)
20 return 1;
23 // crate a source file with a table of square roots
24 fprintf(fout,"double sqrtTable[] = {\n");
25 for (i = 0; i < 10; ++i)
27 result = sqrt(static_cast<double>(i));
28 fprintf(fout,"%g,\n",result);
31 // close the table with a zero
32 fprintf(fout,"0};\n");
33 fclose(fout);
34 return 0;