我正在编写一个使用getline从.txt文件读取文本的程序。我已经在大约一周前编译了该程序,并且该程序运行良好。今天当我尝试再次编译它时,收到以下错误:
/usr/bin/ld: getline: _ZSt4cout: invalid version 3 (max 0)
getline: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
代码如下:
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main(){
string text;
ifstream readfrom;
readfrom.open("read.txt");
while(getline(readfrom, text)){
cout << text << endl;
}
readfrom.close();
return 0;
}
用于编译程序的命令:
g++ getline.cpp -o getline
非常感谢您的帮助
答案 0 :(得分:-1)
更新:通过将代码移至新的文本文件解决了该问题