Record Display

-I have to implement a C++ program to display records that are saved to a '.txt' file (via I/O redirection).

-The program takes the name of the data file as a command-line argument.

-The first record saved in the file has record number 1. The user specifies the records to display by entering an integer:
>If the user enters a positive integer, that integer is the record number of the record to display.
>If the user enters a negative integer, then its value specifies the first record to display and all records after are displayed.
>If the user enters 0, the program exits.

#include <iostream>#define NameSize 20#include <cstdlib>#include <fstream.h>usingnamespace std;
void readRecord(fstream file, int recordNum);
struct student
{
char firstName[NameSize];
char lastName[NameSize];
int score;
}
int main(int argc, char *argv[]) //three conditions to make program stop. 1: reached the end of the main. 2: EXIT() 3: Program crashed.
{
long recordNum=0;
if (argc!=2)
{
cout<<"This is not valid. Please try again.";
return EXIT_FAILURE;
}
fstream file(argv[1],ios_base::in | ios_base::out | ios_base::binary); //ios_base::in is to read. ios_base::out is to write. ios_base::binary is to open the fil e in binary mode.if (!file) //try to open file. if cannot oi
{
cout<<"File: "<<argv[1]<<" fileName"<<endl;
exit(EXIT_FAILURE);
}
readRecord(file,recordNum);
return 0;
}
void readRecord(fstream file, int recordNum)
{
string line;
student record;
while(1)
{
cout<<"Enter the record number you wish to view: "<<endl;
if(getline(cin,line)&& !cin.eof()) //GOOGLE. cin.eof to test if standard input has any errors. WHAT DOES ISTRINGSTREAM DO FOR US?//istringstream: characters can be inserted and/or extracted from the stream using any operation allowed on both input and output.//used to convert numbers to strings.
{
file.seekg(0);
istringstream iss(line);
if(iss>>recordNum)
{
if(recordNum==0)
exit(EXIT_SUCCESS);
elseif(recordNum>0)
{
streampos place=(recordNum-1)*sizeof(student); //what is 'streampos'?
}
else {
streampos place=(recordNum+1)*sizeof(student);
}
}
if(choice=='0')
{
return 0;
}
// after reading the user's input, the program will read the records according to the input value, until the user tells it to stop./* if (choice<0)
{
while(1)
{
fseek(choice);
cout<< //i dont know what to put here;
}
}
if (choice>0)
{
}
*/
}
}
}
//we are supposed to use the getline function to read the line. we are supposed to use 'fseek' and 'istringstream' and 'stringpos' and 'read'. to finish that program//'fseek' is to find a specific spot in the file.//'read' is to be able to read block by block if (argc==2). size of the student struct is fixed. it is efficient.

I have gotten the "entering 0" and the checking if the input is positive or negative part done, but I don't know how to quite continue writing the code. It seems too confusing...