开发者

odd append behaviour

If I have a file containing

manual
/lib/plymouth/themes/default.plymouth

/lib/plymouth/themes/spinfinity/spinfinity.plymouth
10
/lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth
100

and then I open it in a mode, then do

fprintf(f, "/el/derpito.plymouth\n100\n");

why is the file now containing this?

manual
/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

I'd expect the file to be this instead:

manual
/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


Perhaps there is a lonely \n or \cr stuck at the end of the file before you make the write. I wuld open it with a hex editor and see.


my first guess would be that the last character of your file (before the appending) is a newline-character, after which append appends the new line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜