我需要将文本文件中的行保存到一个字符串中,然后将它们插入到数据结构中,但是使用我的解决方案(我认为它非常糟糕) - 我只会将文字保存到我的line
中。将文件中的行保存到新字符串中。 C
FILE * ifile = fopen("input.txt", "r");
char line[256];
while(fscanf(ifile, "%s\n", line) == 1) {
//inserting "line" into data structure here - no problem with that one
}
'“%s \ n”' - >'“%[^ \ n]”' –