基本上我的代碼有問題 - 這是家庭作業,所以寧願不要將它張貼在這裏,原因很明顯。如果這對我來說真的很重要,那麼我將不得不如此堅持。fgets - 正在省略最後一行c
我讀2個文本文件,它也有一個分隔符,這些值來自命令行,只是假設,在這種情況下,分隔符是XX
File a
a
b
c
File b
d
e
Output should be
axxd
bxxe
cxx
的問題是,我的代碼只是沒有按「做T的最後一行正確
我得到的
axxd
bxxe
的輸出,我希望你們能收集什麼,我做錯了沒有我張貼我的所有代碼,但我的邏輯工作Ø這個原則;
while not at the end of the file for files a and b
get a line using fgets from a
create a character pointer and set it to the first occurrence of \n in the line using strchr
if the pointer isn't null
set the pointers value to be the end of line
get the line from b as above
and now write the line from a, the separator and the line from b to file
顯示您遇到問題的最小C代碼示例 – 2010-03-06 13:14:33
Almsot不可能,因爲它只有8行代碼:S – Biscuit128 2010-03-06 13:18:01
您不願發佈8行代碼?使用while()和fgets()的東西是最高安全性的問題? – 2010-03-06 13:21:08