This is my first attempt at creating a program and I am having great problems. The program is meant to scan a file and increment a counter if specific words are found. Can anyone let me know where I'm going wrong,Thanks
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <conio.h>
using namespace std;
int main (void)
{
string string1;
int location;
char userName; //The students log-in name
int markCounter //Counter for adding up students mark
system("cls"); // Clear the screen
cout << "Marking Program" << endl << endl;
ifstream infile("checkUserName.txt", ios::in);
//Get students username
cout << "Enter Students Username: ";
cin >>string1;// entered username
// Check students username validity
userName.find_first_of("checkUserName.txt");
if string1 /found then
cout << "Username not found"<<;
else
ifstream infile("string1.txt", ios::in); //open students file
ifstream infile("markScheme.txt", ios::in);
while (getline(markScheme, line1)) {
if (line1.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line2)) {
if (line2.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line3)) {
if (line3.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line4)) {
if (line4.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line5)) {
if (line5.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line6)) {
if (line6.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line7)) {
if (line7.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line8)) {
if (line8.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line9)) {
if (line9.find(search) != string::npos)
++1 counter;
while (getline(markScheme, line10)) {
if (line10.find(search) != string::npos)
++1 counter;
//Display students mark
cout << "Students mark is (counter)";
}
}