为了正确地表达这个问题,我在/opt/plan9/中安装了plan9port,当我从/opt/plan9/bin/fortune运行fortune程序时,它工作得很好。(读取/opt/plan9/lib/fortune和/opt/plan9/lib/fortune.index的财富排行榜)。当我在c代码(test.c)中使用
char* o
财富是由%描述的,所以一个示例财富文件可能如下所示:This is sample fortune 1This is %isrepeatedThis is sample fortune 3This fortune %is unique正如您所看到的,财富可以跨越多条线我考虑了一种让awk忽略以%开头的行的方法,但有些财富共享相同的行,但总体上并不相同(例如我的示例中的最后两行)