将文件中的行保存到新字符串中。 C
Save lines from file into new string. C
我需要将文本文件中的行保存到字符串中,然后将它们插入到数据结构中,但是使用我的解决方案(我认为这真的很糟糕)- 我只将单词保存到我的 line
.
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
}
我需要将文本文件中的行保存到字符串中,然后将它们插入到数据结构中,但是使用我的解决方案(我认为这真的很糟糕)- 我只将单词保存到我的 line
.
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
}