/*****************************************************************************
M
Lab 5.1 A B
*****************************************************************************/
//Include header files
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
usingnamespace std;
//Declare main
int main()
{
//Declare variables
int numberOfstudents;
int counter = 0;
string firstName, lastName;
fstream USBout;
//Prompt the user to enter the number of students
cout << "Please enter the number of the students in this class ";
//Get the number of students
cin >> numberOfstudents;
//If number Of students is greater than 0
if (numberOfstudents > 0);
//Open the output file
USBout("F:students.txt");
//While the counter is less than or equal to number of students
while (counter <= numberOfstudents);
{
//Prompt user for first and last name
cout << "Please enter the First and Last Names of the students " << endl;
//Get the first and last name
cin >> firstName, lastName;
//Store in output file
USBout >> firstName >> lastName;
//Update the counter
counter++;
}
//Else display a message
else cout << "No students in class" << endl;
//Display a message to the user when the program is done
cout << "Done" << endl;
//End the main function
return 0;
}
Errors:
Error 2 error C2064: term does not evaluate to a function taking 1 arguments 33 1
Error 3 error C2181: illegal else without matching if 52 1
4 IntelliSense: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type 33 2
5 IntelliSense: expected a statement 52 2
Warning 1 warning C4390: ';' : empty controlled statement found; is this the intent? 33 1
When i try to start without debugging a pop up says Unable to start program....... The system cannot find the file specified