我有一個純文本文件,其中有很多行。每行包含5個字。例如:如何在爆炸時刪除尾隨換行字符
cat bat rat mat sat
hello hi howdy namaste salaam
here there where nowhere somewhere
a b c d e
......
......
現在我使用fgets()
函數逐一檢索這些行。這些線條被完美地檢索出來,但是當我構成5個單詞的數組的字符串時,我發現尾部的line feed
字符也包含在數組中。
那麼如何去除尾部line feed
字符而爆炸?
是否將它添加到最後一個元素,以便第一行有'sat \ n'? – Nanne 2011-06-12 07:49:15