#include <fstream>
#include <iostream>
using namespace std;
int main(){
ifstream input;
input.open("kr.txt");
int n;
input >> n;
for(int i = 0; i < n; i++){
char line[16];
input.ignore(256, '/n');
input.get(eil, 16);
}
return 0;
}
我在“input.ignore()”处收到警告。 我的文件看起来像这样。 15 个空格将行的开头与第一个数字分隔开。
2
Rimas 195.5 45
Robertas 165 13
最佳答案
/n
是由两个字符组成的常量,'/'
和 'n'
并且您没有将其作为字符串引用,使用 "
,但作为字符,使用 '
,因此发出警告。
也许您想使用反斜杠而不是斜杠,即 '\n'
?
关于C++: "Multi-character character constant"从文件读取到 char 数组时发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53326199/