getline() help

I'm working on this assignment, and my teacher asked us to use the getline() function. I'm still not sure how to use it because when i try and compile this it comes up with some crazy errors
1
2
3
 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>]

I ran this program with cin >> first, and it worked out well except it would not read past spaces. Can anyone help me out with this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}
What line of text are you trying to read in the single character named let?!!!
Can I not use getline for a single char?
And how do I ignore spaces when doing the function?
Most input functions have delimiting characters, like \n newlines, spaces, and others, look up specific library documentation regarding each one.
I figured it out, I had to have let as an array rather than a variable and it worked out great. Thanks for the help.
Topic archived. No new replies allowed.