1 // A simple program that builds a sqrt table
6 int main(int argc, char* argv[])
8 // make sure we have enough arguments
13 std::ofstream fout(argv[1], std::ios_base::out);
14 const bool fileOpen = fout.is_open();
16 fout << "double sqrtTable[] = {" << std::endl;
17 for (int i = 0; i < 10; ++i) {
18 fout << sqrt(static_cast<double>(i)) << "," << std::endl;
20 // close the table with a zero
21 fout << "0};" << std::endl;
24 return fileOpen ? 0 : 1; // return 0 if wrote the file