C Program to read text File on Disk using FREAD function

C Program to read text File on Disk using FREAD function 


Its Basic C Program to read any text from disk using FRead Function which belongs to stdio.h, using this function with file pointers you can read the TEXT contents of any file. 

#include 
#include 

int main()
{
    int cur_char;
    FILE *out_file;

    out_file = fopen("test.txt", "w");
    if (out_file == NULL) {
        fprintf(stderr,"Can not open output file\n");
        exit (8);
    }

    for (cur_char = 0; cur_char < 128; ++cur_char) {
        fputc(cur_char, out_file);
    }
    fclose(out_file);
    return (0);
}




Related Links :

C Program accept 10 values and sort them

C Program accept 10 values and sort them


#include
#include
 void main()
 {
  int num[10],i,j,temp;
  clrscr();
  printf("\n Enter 10 values of an array...........\n");
  for(i=0;i<10;i++)
   scanf("%d",&num[i]);

 printf("\n array before sort .........\n");
  for(i=0;i<10;i++)
   printf("%d\t",num[i]);

 for(i=0;i<9;i++)
 {
  for(j=i+1;j<10;j++)
  {
   if(num[i]<num[j])
   {
    temp=num[i];
    num[i]=num[j];
    num[j]=temp;
   }
  }
 }

 printf("\n array after sort .........\n");
  for(i=0;i<10;i++)
   printf("%d\t",num[i]);

   getch();
  }




Related Links :

C Program to find Sum of Series using Function

C Program to find Sum of Series using Function



#include
#include
long int sum_sqr(int);
main()
 {
  int n;
  clrscr();
  printf("\n Enter any number : ");
  scanf("%d",&n);
  printf("\n Sum of Series is %ld",sum_sqr(n));
  printf("\n\n Press any key to exit. . .");
  getch();
}

 long int sum_sqr(int m)
 {
  if(m<=1)
   return 1;
  else
   return (m*m+sum_sqr(m-1));
  }

Related Links :

C Program to calculate Sum and Average of Marks and validate also

C Program to calculate Sum and Average of Marks and validate also


#include
#include
main()
{
 int m[5],i,sum=0,avg;
 clrscr();
 printf("Enter the marks of five subjects=");
 for(i=0;i<=4;i++)
 {
  scanf("%d",&m[i]);
 }
 for(i=0;i<=4;i++)
 {
  if(m[i]>100)
  {
   printf("Invalid\n");
   break;
  }
  else
  {
   sum=sum+m[i];
  }
 }
 printf("Sum=%d\n",sum);
 avg=sum/5;
 printf("Avg=%d",avg);
 getch();
}


Related Links :

C While Loop Program to show Difference Between Pre-Increment and Post-Increment

C While Loop Program to show Difference Between Pre-Increment  and Post-Increment 



#include

 int main(void) {
  int i;
 
  i = 0;
  while(i++ < 5) {
   printf("%d\n", i);
  }
  printf("\n");
  i = 0;
  while(++i < 5) {
   printf("%d\n", i);
  }
  return 0;
 }



Related Links :

C Program to show Example of While .. Continue

C Program to show Example of While .. Continue 




#include

 int main()
 {
  int i;

  i = 0;
       while ( i < 20 )
       {
            i++;
            
            printf(" to see\n");
continue;
printf("Nothing to see\n");
       }
       return 0;
 }


Related Links :

C Program to print 1 to 10 Numbers using While and Break

C Program to print 1 to 10 Numbers using While and Break


#include

 int main()
 {
       int i;

  i = 0;
  while ( i < 20 )
       {
            i++;
            if ( i == 10)
                 break;
       }
       return 0;
 }


Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!