Counting Certain Characters

I am creating a program in which the user inputs a letter and a phrase and the comp outputs the amount of that certain letter in the phrase.
My code is as follows:

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
27
#include <iostream>

using namespace std;
int countLetters(char[], char[]);
int main()
{
   char let[256];
   char text[256];
   cout << "Enter a letter: ";
   cin >> let;
   cout << "Enter text: ";
   cin >> text ;
   countLetters(let, text);
   return 0;
}

int countLetters(char let[], char text[])
{
   int num = 0;
   for(int i = 0; text[i]; i++)
   {
      if (text[i] == let[i])
         num++;
   }
   cout << "Number of '" << let << "'s: "
        << num << endl;
}


The output is always 0. Any help to push me in the right direction would be greatly appreciated!
A letter is not an array:
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
27
#include <iostream>

using namespace std;
int countLetters(char[], char[]);
int main()
{
   char let[256];
   char text[256];
   cout << "Enter a letter: ";
   cin >> let;
   cout << "Enter text: ";
   cin >> text ;
   countLetters(let, text);
   return 0;
}

int countLetters(char let[], char text[])
{
   int num = 0;
   for(int i = 0; text[i]; i++)
   {
      if (text[i] == let[i])
         num++;
   }
   cout << "Number of '" << let << "'s: "
        << num << endl;
}
I changed the program up a little, because I want to start using getline() instead of cin >> let,text.
How exactly do I use it? I use getline(cin, let); and i come up with an error saying:
hw15.cpp:32: error: no matching function for call to âgetline(std::istream&, char&)â

What exactly do I need to do?
Anyone have any ideas?
I'm busy, but I post my correct code : (You should review it)
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
27
28
29
#include <iostream>

using namespace std;
int countLetters(char, char[]);
int main()
{
   char let;
   char text[256];
   cout << "Enter a letter: ";
   cin >> let;
   cout << "Enter text: ";
   cin >> text ;
   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;
}

Any question?
Just one.
I was challenged to use the getline() function instead of cin. How exactly would I do it? I can't figure out how to use that function.
Sorry, my compiler doesn't support getline().
No worries! Thanks for all the help.
Topic archived. No new replies allowed.