Good day everyone! I have the codes for such a problem where, to create a program that counts how many times the second string appears on the first string. Here it is:
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
char first [100], second;
int count;
cout <<"Enter 1st String: ";
cin.get (first, 100);
cout <<"Enter 2nd String: ";
cin >> second;
for (int i = 0; i < strlen (first); i++)
{
if (tolower(first[i]) == tolower(second))
{
count++;
}
}
cout << "THE STRING " << "'" << second << "'" << " appeared " << count << " times in " << first << ".";
getch ();
return 0;
}
Hope anyone can help me. :(