Look up the man page for

Submitted by peter on Sat, 01/04/2020 - 16:00

Programming in C on Linux often requires a visit to forums to find answers to tricky questions. A common comment in forums starts with the following advice.
Look up the man page for ___

"man" is a reference to a manual often included in Linux distributions. If you want to look up the use of function x(), you can enter the command man x in the 1930s teletype style Terminal window. Primitive? Yes. Useful? Sometimes.

As a test of that advice, I looked up the man page for one function. The man page shows several variations and none work. None of them compile. If you cannot get past the compilation of C, you cannot test the functionality of a function.

The page does not show examples of use. I searched the Web for examples of use and looked at over ten Web pages, testing every example of use. Some pages had multiple examples. Only one example worked. The working example fails to fit the function description from the man page.

Look at the man page to find a formal description that might be useful. The format description might include comments about the limitations of the function. Test every variation they show. If none work, allocate an hour to work through endless online code examples that might work on one version of Linux somewhere but probably not on your machine.

Create a test program for the function. Test each example one at a time. Place each failed example in comments describing the failure. When you do find an example that works, fill the page with comments and keep the example.

The next time you apply a major update to your Linux installation, you might have to start again with some of your basic examples to find out what the updated compiler likes.