#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 can help..
gaurav23 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
gaurav23 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.