基本上我的代码有问题——这是家庭作业,所以出于明显的原因,我宁愿不把它贴在这里。如果这样做对我来说真的很重要,那么我将不得不这样做,因为我被困住了。
我正在阅读 2 个文本文件,它也有一个分隔符,这些值来自命令行,假设这种情况下的分隔符是 xx
File a
a
b
c
File b
d
e
Output should be
axxd
bxxe
cxx
问题是我的代码没有正确执行最后一行
我得到一个输出
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