Answers

2014-04-18T18:45:05+05:30
Void read_ints (const char* file_name)

FILE* file = fopen (file_name, "r"); 
 int i = 0;
  fscanf (file, "%d", &i);     
while (!feof (file)) 
  {     
  printf ("%d ", i);     
 fscanf (file, "%d", &i);    
     }
  fclose (file);    
    }
int c;
FILE *file;file = fopen("test.txt", "r");
if (file) {   
 while ((c = getc(file)) != EOF)     
   putchar(c); 
   fclose(file);
}

this is sample to take integer from text file...


#include <iostream>
#include <conio.h> 
void main ()
{
clrscr();
int array [3], t;
for (int  x=0; x<3; x++)

   cout << "Enter integer number" << x+1 << " : " << endl; 
   cin<< array[x];
}
for (x=0; x<3; x++)
{
for (int y=0; y<2; y++)

   if(array[y]>array[y+1]) 
   { 
      t=array[y];   
    array[y]=array[y+1];
        array[y+1]=t;   
 }
}
}
cout << "The integers in ascending order are :
 ";for (x=0;x<3;x++)
cout << endl << array[x];
getch();
}
this for 
ascending order
1 5 1