I am beginner at c++, so I need some help and it would be very nice if you could help me.
I have a task to find out how many words (e. g. "boy") are in the text. But the problem is that some words may begin with upper letters (e. g. "Boy"). So I had an idea to transform the word in all upper letters and then compare with the word that I need to find. I use type string for reading words in the text and that's why the functions "strlwr" and "strupr" are unsuitable, because thay are intended for type char (line 26). What should I do in this situation?
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdio.h>
#include <string.h>
usingnamespace std;
//------------------------------------
int Quantity (string eil);
//------------------------------------
int main ()
{
string eil;
ifstream is;
ofstream os;
is.open ("Text.txt");
os.open ("result.txt");
int x = Quantity(eil);
int k = 0;
int i = 1;
while (i <= x)
{
is >> eil;
if ((!is.eof()) && (strlwr(eil) == strlwr("boy")))
{
k = k + 1;
cout << eil;
}
i = i + 1;
}
cout << k;
is.close();
os.close();
return 0;
}
//------------------------------------------
int Quantity (string eil)
{
ifstream is;
is.open("Text.txt");
int k = 0;
while (!is.eof())
{
is >> eil;
if (!is.eof())
{
k = k + 1;
}
}
is.close();
return k;
}