Hi all,have this code:
Hi all,have this code:
How do i implement binary search to display item.. found at index..
#include "stdafx.h"
#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
struct sDetails{
int kNum;
string Name;
};
int _tmain(int argc, _TCHAR* argv[])
{
sDetails students[5];
ifstream infile;
infile.open("student.txt");
for (int i = 0; i < 5; i++)
{
infile >> students[i].kNum >> students[i].Name;
}
cout << "The Class List Is:\n";
cout << "KNUM\t\tNAME\n";
cout << endl;
for (int i = 0; i < 5; i++)
{
cout << students[i].kNum << setw(15) << right << students[i].Name << endl;
}
infile.close();
return 0;
}