Use C to invoke the Python-m Pydoc instruction to implement the command line directly using Pydoc
1 //Win32Project1.cpp: Defines the entry point of the console application. 2 //3 4 5#include <stdio.h>6#include <stdlib.h>7#include <string.h>8 9 intMainintargcChar*argv[])Ten { One A Charpsbuffer[ -]; -FILE *Ppipe; - the /*Run DIR So, it writes it output to a pipe. Open This - * Pipe with read text attribute so that we can read it - * Like a text file. - */ + Charpy[ -] ="python3-m Pydoc"; - if(argv[1]) + { Astrcat (PY, argv[1]); at //printf ("%s", py); - } - - if(Ppipe = _popen (py,"RT")) ==NULL) -Exit1); - in /*Read pipe until end of file, or an error occurs.*/ - to while(Fgets (Psbuffer, -, ppipe)) + { - printf (psbuffer); the } * $ /*Close pipe and print return value of Ppipe.*/Panax Notoginseng if(feof (ppipe)) - { theprintf"\nprocess returned%d\n", _pclose (ppipe)); + } A Else the { +printf"error:failed to read the pipe to the end.\n"); - } $ $}
Pydoc under Windows