The following program executes without any errors, but the output is not what is expected. The code is correct down till the opening of the MarkScheme.txt file, but the student mark is not displayed on the screen, any thoughts
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
cout << " Marking Program "; //Start of program
string username;
cout << "Enter Students Username:";
cin >> username;
string filename = username + ".txt";
ifstream file(filename.c_str());
if (!file) {
cerr<<"Username not found"<<endl;
return EXIT_FAILURE;
}
{ ifstream in("MarkScheme.txt");
if (!in){
cerr<<"Mark Scheme not found"<<endl;
return EXIT_FAILURE;
}
}
//beginning of section of code not working
string search;
int count(0);
if (!getline(cin, search)) {
count;
}
string line;
while (getline(cin, line)) {
if (line.find(search) == string::npos)
++count;
}
cout<< "students mark is"<<count<<"out of 10"<<endl;
return EXIT_SUCCESS;
}