Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Man page in C application

I’m currently working on a little project to test my knowledge in writing C applications.
I try to create a man page which shall open, once app --help is typed. How do I change the path, so when I send my work to friends they can also run app --help and the man page will open.

Is there any possibility to run a command from a C file like:

if (strcmp(argv[1], "--help") {
   run_in_command_line("man ./app.8");
}

Or are there other, better, ways to do it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

run_in_command_line may be a call to system(), but this will work only if run into a terminal.

Launching man ./app.8 from your executable is definitely a bad idea, because it would require that the run would be made in the right directory. Such a constraint is considered as bad. Prefer:

  • an installation procedure that will install the executable and the man,
  • use system("man app") in the code, or preferably a help command that gives basic informations and then suggests to read the man for complete information.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading