What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

C++ Lab Codings

C++ Program for to read the content of the file sort.

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char c[25],str[20][20],d[20];
int j,count;
j=count=0;
ifstream ifs("d:\\first1.txt");
ofstream sort("d:\sort.txt");
cout<<"\n\n\t\tFILE CONTENT BEFORE SORTING\n\n";
while(!ifs.eof())
{
ifs.getline(c,20);//READING FROM THE FILE
strcpy(str[count],c);
cout<<c<<endl;
if(count)
{
/*sorting*/
strcpy(str[count],c);
for(j=0;j<=count;j++)
{
if(strcmpi(str[count],str[j])<0)
{
strcpy(d,str[j]);
strcpy(str[j],str[count]);
strcpy(str[count],d);
}
}
}
count++;
}
cout<<"\n\nFILE CONTENT AFTER SORTING";
for(j=0;j<count;j++)
{
sort<<str[j]<<endl;//writing
cout<<"\n"<<str[j];
}
getch();
}

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com