Hi all, I have a problem reading data from my file
for example this is my textfile
CODE MARKER //Names of columns in my table
PKY KELLYS
ELM ELMANS
OOC OLIVER
QRT QUATAR
A user is asked for code, when the code is entered, the corresponding name is displayed
eg when a user enters PKY, in the INPUT, KELLS is displayed on the screen
below is my code
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include "stu_data.h"
#include "markernames.h"
using namespace std;
main()
{
const int SIZE = 15;
char marker_code[3+1];
char marker_name[SIZE+1];
int i;
char request[20];
fstream inoutmarker("markernames.txt", ios::in |ios::out);
inoutmarker.seekg(0, ios::beg);
if (inoutmarker.fail())
{
cerr<<"markernames file error"<<endl;
return 1;
}
for(i=0; i< SIZE; i++)
{
inoutmarker >> marker_code >> marker_name;
}
cout<<"Please enter Marker Code: ";
cin >>request;
for(i=0; i < SIZE; i++)
if(strncmp(marker_code, request,3)== 0)
{
cout << marker_code << marker_name<<endl;
}
return 0;
inoutmarker.close();
system("PAUSE");
}