开发者

odd append behaviour

开发者 https://www.devze.com 2023-01-24 12:55 出处:网络
If I have a file containing manual /lib/plymouth/themes/default.plymouth /lib/plymouth/themes/spinfinity/spinfinity.plymouth

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

精彩评论

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