我想使用std :: getline,但我的編譯器告訴我getline沒有被識別?std沒有會員'getline'?
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <fstream>
#include <cstdlib>
int main(){
using namespace std;
string line;
ifstream ifile("test.in");
if(ifile.is_open()){
while(ifile.good()){
getline(ifile,line);
}
}
}
這很容易。 ;] – karlphillip 2011-04-25 17:36:23
我認爲cstring和字符串是相同的,但cstring是爲c + +? – pighead10 2011-04-25 17:36:37
@Pig Head:'cstring'用於C-in-C++。它在'std'命名空間中定義了所有舊的C字符串函數('strlen'等)。 – cHao 2011-04-25 17:38:51