getline()
123
error: no matching function for call to âstd::basic_istream<char, std::char_traits<char> >::getline(char&)â /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/istream:593: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(_CharT*, std::streamsize, _CharT) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/istream:405: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(_CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<char>]
cin >>
1234567891011121314151617181920212223242526
int main() { char let; char text[256]; cout << "Enter a letter: "; cin.getline(let); cout << "Enter text: "; cin.getline(text, 256) cin.ignore(); int nCount = countLetters(let, text); cout << "Number of '" << let << "'s: " << nCount << endl; return 0; } int countLetters(char let, char text[]) { int num = 0; for(int i = 0; text[i]; i++) { if (text[i] == let) num++; } return num; }
let