#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <time.h>
using namespace std;
void Write(char word, char sentence,int count, int cnt_word)
{
ofstream fout("marks.txt", ios_base::app);
if (word == sentence)
{
cnt_word++;
for (int i = 0; i < count; i++)
{
fout << "Count of " << word << "is: " << cnt_word << "\n";
}
}
fout.close();
}
void Read( char word, char sentence)
{
ifstream fin("marks.txt");
char str[256];
if (!fin.is_open())
{
cout << "I cant open file\n";
}
else
{
while (!fin.eof())
{
fin.getline(str, 128);
cout << str << "\n";
}
}
fin.close();
}
int main()
{
char word[100];
char sentence[100];
cout << "Enter word: ";
cin.get(word, 100);
cout << "Enter sentence: ";
cin.get(sentence, 100);
int cnt_word = 0;
int count = 1;
Write(*word, *sentence, count, cnt_word);
Read( *word, *sentence);
system("pause");
return 0;
}