No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
Re:
Hi guys, If i have a file like the one below what would be the best/easiest way to sort the words in alphabetical order. thanks. with an equal mix of biosolids to make the compost Sawdust is on their greens Compost applied properly will enhance growth of grass flowers shrubs … |
|
#include<fstream.h> #include<conio.h> #include<string.h> #include<stdio.h> void main() { clrscr(); ofstream fout("a"); fout<<5<<"\n"<<3<<"\n"<<2<<"\n"<<4<<"\n"<<1; fout.close(); ifstream fin("a"); int i,j,k,l=0,m,n,o; while(fin) { fin>>i; l++; } l--; fin.close(); fstream fin1("a",ios::ate,ios::in); fin1.seekg(0); for(i=0;i<l-1;i++) { for(j=0;j<l-i-1;j++) { o=fin.tellg(); fin1>>m; fin1>>n; if(m>n) { fin1.seekg(o); fin1<<n; fin1<<m; fin1.seekg(o+1); } } } } //file sorting is not working if anyone … |