我正在學習C++,並且仍然保持運行到愚蠢的問題,因爲我與C++庫,以及常見的錯誤又不熟,等函數getline(isstream,字符串)在C++
現在,以下一塊我的代碼失敗:
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
void getInt(int & val){
string output;
getline(cin output.c_str());
val = atoi(output.c_str());
}
,並給了我這個錯誤,當我嘗試編譯:
test.cpp: In function void getInt(int&):
test.cpp:51: error: expected) before output
test.cpp:51: error: no matching function for call to getline(std::istream&)
我在做什麼錯?我覺得我失去了一些明顯的東西。
'getline(cin output.c_str());'缺少逗號。 – 2013-02-23 18:46:58
@Daniel Fischer哇 - 簡單修復。我討厭在終端工作與emacs大聲笑。你能發表一個答案,以便我可以接受嗎?你是第一個。 = P – Jonathan 2013-02-23 18:47:55
真的嗎?這是你的問題?你沒有做任何調試? – 2013-02-23 18:49:47