Parsing command-line arguments in C?

后端 未结 12 830
眼角桃花
眼角桃花 2020-11-22 16:23

I\'m trying to write a program that can compare two files line by line, word by word, or character by character in C. It has to be able to read in command line options

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 16:53

    Docopt has a C implementation that I thought was quite nice: https://github.com/docopt/docopt.c

    From a man-page standardized format describing command line options, docopt infers and creates an argument parser. This got started in python; the python version literally just parses the docstring and returns a dict. To do this in C takes a little more work, but it's clean to use and has no external dependencies.

提交回复
热议问题