cheers for the toot, i know i should post my code but i keep changing it and i don't have one that is a good example of what i want, i'm mostly playing with fucntion till i find what i need so it's a bit of a mess,
here a small example of what i mean there might be mistakes as it's just to give you an idea so please don't pick on the small things just try to get the idea of what i am doing THX.
Code:
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
struct data {
int num;
char des[20];
};
int main(int argc, char *argv[])
{
int num1, len;
char des1[20], * buffer;
cout<<"Please enter item number > ";
cin>> num1;
cout<<"\nplease enter desciption > ";
cin.ignore(1,'\n');
cin.getline(des1,20);
data item;
item.num=num1;
item.des[20]=des1[20];
//opening a file stream
ofstream ofile;
ofile.open("whattha.ddf",ios::app);
ofile<< des1 <<" "<< num1 <<endl;
ofile.close();
//reading the file to a buffer!!!!!!!!!!!!!!!
ifstream ifile;
ifile.open("whattha.ddf");
ifile.seekg(0,ios::end);
len=ifile.tellg();
ifile.seekg(0,ios::beg);
buffer = new char [len];
ifile.read(buffer,len);
//display contents of buffer (or file)
cout.write(buffer,len);
cin.get();
what i want to do is once i have sent information to the file i want to be able to retrieve it in a sorted manner ,
say if i input item number 12345 with the description "cheese"
i want to be able to search the item number and find the description?
i am stumped and have been for a while, where can i find the answer or has anyone got some valuable tips?