Laboratory Exercises, C++ Programming
Laboratory Exercises, C++ Programming
Laboratory Exercises, C++ Programming
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Tools for Practical <strong>C++</strong> Development 15<br />
A4. (Optional, VPATH is difficult) Create a new directory, src, for <strong>C++</strong> lab source code and copy<br />
the source files from lab 1 into it. In a parallel directory build, install the Makefile, and<br />
modify it so that you can build the programs (and possibly libraries), standing in the build<br />
directory. The all target, which should be default, should build your ltest, encode, and<br />
decode programs. No command should write to the src directory.<br />
2 Debugging<br />
Consider the following program (reciprocal.cc):<br />
#include <br />
#include // for atoi, see below<br />
double reciprocal(int i) {<br />
return 1.0 / i;<br />
}<br />
int main(int argc, char** argv) {<br />
int i = std::atoi(argv[1]); // atoi: "ascii-to-integer"<br />
double r = reciprocal(i);<br />
std::cout