【发布时间】:2011-05-06 15:36:46
【问题描述】:
如果我有一个文件包含
手册 /lib/plymouth/themes/default.plymouth /lib/plymouth/themes/spinfinity/spinfinity.plymouth 10 /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth 100
然后我以a模式打开它,然后做
fprintf(f, "/el/derpito.plymouth\n100\n");
为什么文件现在包含这个?
手册 /lib/plymouth/themes/default.plymouth /lib/plymouth/themes/spinfinity/spinfinity.plymouth 10 /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth 100 /el/derpito.plymouth 100
我希望文件是这样的:
手册 /lib/plymouth/themes/default.plymouth /lib/plymouth/themes/spinfinity/spinfinity.plymouth 10 /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth 100 /el/derpito.plymouth 100
【问题讨论】:
-
试试 Notepad++ 或其他可以显示空白的好编辑器。原文件末尾似乎多了一个\n。
-
奇怪的是,没有。我已经解决了在
r中打开文件,在w中打开另一个文件,然后手动复制行直到我需要添加更多行。然后我删除第一个文件并将新文件重命名为旧文件的名称。这显然不优雅,但它是迄今为止我得到的最佳解决方案。