C++ C++;从文本文件中筛选内容
我曾经想提取一行文本[1],[2]。。。[n] 找到了。但我似乎无法将一行存储到以[1]开头的字符中C++ C++;从文本文件中筛选内容,c++,filter,C++,Filter,我曾经想提取一行文本[1],[2]。。。[n] 找到了。但我似乎无法将一行存储到以[1]开头的字符中 void ExtractWebContent::filterContent(){ char str [10]; ifstream reading; reading.open("file_Currency.txt"); while (!reading.eof()){ reading.get(str,10,'[1]'); cout &
void ExtractWebContent::filterContent(){
char str [10];
ifstream reading;
reading.open("file_Currency.txt");
while (!reading.eof()){
reading.get(str,10,'[1]');
cout << str << endl;
}
cout << str;
reading.close();
}
void ExtractWebContent::filterContent(){
char-str[10];
流式阅读;
reading.open(“file_Currency.txt”);
而(!reading.eof()){
阅读。获取(str,10,'[1]');
cout最大的错误是将单个字符视为字符串。第三个参数应该是单个字符分隔符,即分隔文件中记录的字符。如果在编译时添加编译器选项-Wall
,则会收到关于单个字符中包含多个字符的警告文字
做你想做的事情的一种方法是使用。谢谢你的更正。但我仍然不知道如何开始。我现在做的是获取行,希望消除不需要的char.void ExtractWebContent::filterContent(){string str;ifstream reading;reading.open(“file_Currency.txt”);while(!reading.eof()){getline(reading,str,”);cout
CAPTION: Currencies
Name Price Change % Chg
[80]USD/SGD
1.2606 -0.00 -0.13%
USD/SGD [81]USDSGD=X
[82]EUR/SGD
1.5242 0.00 +0.11%
EUR/SGD [83]EURSGD=X