Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试“美化”一些创建日志文件的代码,并且在日志文件中我想打印输入文件的名称以及在格式良好的#-box 中使用了哪些设置。我需要能够获得输入参数的长度,该参数必须由 GNU getopt 存储在某个地方,因为它是内部 malloc,至少我认为他们是这样做的。
有谁知道如何获得该价值?然后我可以使用一些简单的微积分来查看我需要在评论框中的最后一个文本字母之后添加多少空格;)
您的代码在哪里存储值,它在
extern const char *optarg;
变量,您可以简单地使用它strlen()来计算字符串的长度。
strlen()