can anybody give me an idea how to sort string in alphabetical order in file.text after user input string and in the file already had a list of string?
which is the best,let user input the all string first then sorting it or sorting if after user input the string?
#include <iostream.h>
#include <fstream.h>
void main()
{
fstream kamus("Adkjektif.txt",ios::in | ios::out | ios::app);
const size = 30;
char kata2[size];
cout<<"input string (end for stop)"<<endl;
for(;;)
{
cin.getline(kata2,size);
if (strcmpi(kata2,"end")==0)
break;
else
kamus<<kata2<<endl;
}
kamus.close();
}
this is the content of the file
small
tall
big