I had got an assignment for sorting some data..
"Make a c++ program which takes data from a TEXT FILE, then sort it"..
i made this program..
#include <iostream.h>
#include <conio.h>
int main ()
{
clrscr();
int sort[8];
cout<<"Enter DATA to be Sorted\n";
for(int get=0;get<=7;get++)
cin>>sort[get]; //cin saves the values in array SORT
for(int a=0; a<=7;a++) //FOR loop runs 8 times(0-7)..8-Passes
{ //Loop BODY starts
for(int b=0;b<=7; b++)
{
int save=sort[b];
if(sort[b]>sort[b+1])
{ //if-BODY starts
sort[b]=sort[b+1]; //Assigns value, if sort[b+1] is greater than sort[b]
sort[b+1]=save; //Assign value of save to b+1
} //IF body ends
} //Nested FOR body ends
} //First FOR body ends
cout<<"\nSorted data is:";
for(int i=0;i<=7;i++) //FOR loop to print the values
cout<<sort[i]<<" "; //COUT displays the sorted array
getch(); //Freezes screen until gets a character from keyboard
return 0; //Return Statement
}
Now he is saying that this code gets data from Keyboard, while it is supposed to get from a TEXT FILE,, so he suggested to use some sile STREAMS....
Can any one help me,, how to do it..??