Multiple programs... ఇందులో ఉన్నాయి

save the  following as KOSHISH.C
#include<stdio.h>
#include<conio.h>
void main()
{
 printf("\n satyamu paluku");
 printf("\n 12  nijam cheppu");
 getch();
}

----------------------------------------------------------------------------------------
Save the following as FNAYA4.C 
/*program written by vikram bhayya after he understood the content given in LET US C book*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()

{
 FILE *fptrs,*fptrd;
 char ch;
 fptrs=fopen("KOSHISH.C","r");
 if(fptrs==NULL)
 {
  puts("\n cannot open source file");
  exit(1);
 }
 fptrd=fopen("KOSHISH2.C","w");
 if(fptrd==NULL)
 {
  puts("\n cannot open destination file");
  fclose(fptrs);
  exit(2);
 }

 while(1)
 {
  ch=fgetc(fptrs);
  if(ch==EOF)
   break;
  else
   fputc(ch,fptrd);
 }
 fclose(fptrs);
 fclose(fptrd);
 getch();
}

------------------------------------------------------------------------------------------
Save as FNAYA3.C

/*program written by vikram bhayya after he understood the content given in LET US C book*/
#include<stdio.h>
#include<conio.h>
void main()

{
 FILE *fptr;
 char ch;
 int nol=0,not=0,nob=0,noc=0;// no of lines, tabs,blanks, characters
 fptr=fopen("KOSHISH.C","r");
 while(1)
 {
  ch=fgetc(fptr);
  if(ch==EOF)
   break;
  noc++;
  if(ch==' ')
   nob++;
  if(ch=='\t')
   not++;
  if(ch=='\n')
   nol++;
 }
 fclose(fptr);
 printf("\n no of characters = %d",noc);
 printf("\n no of blanks = %d",nob);
 printf("\n no of tabs = %d",not);
 printf("\n no of lines = %d",nol);
 getch();
}

--------------------------------------------------------------------------------------------

save as FNAYA.C
#include<stdio.h>
#include<conio.h>
void main()

{
 FILE *fptr;
 char ch;
 fptr=fopen("KOSHISH.C","r");
 while(1)
 {
  ch=fgetc(fptr);
  if(ch==EOF)
   break;
  printf("%c",ch);
 }
 fclose(fptr);
 getch();
}


-------------------------------------------------------------------------------------------
save as FNAYA2.C
#include<stdio.h>
#include<conio.h>
void main()
{
  FILE *fptr;
  char ch;
  fptr=fopen("cab.c","r");
  if(fptr==NULL)
  {
   printf("\n cannot open file cab.c");
   exit(1);
  }
  getch();
}

--------------------------------------------------------------
save as F_create.c

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
clrscr();
fptr=fopen("chennai.txt","w");
printf("\n input the text \n");
ch=getchar();
while(ch!='z')
{
 fputc(ch,fptr);
 ch=getchar();
 }
 fclose(fptr);
 getch();
}

------------------------------------------------------------------------------------------
SAVE as F_WR.c

/* program to illustrate reading the content of a file using fgetc():
 taken by vikram bhayyA from S Chand after understanding how it works */
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
clrscr();
fptr=fopen("nellore.txt","w");
if (fptr==NULL)
 {
  printf("\n cannot open the file");
  exit(1);
 }
 printf("\n write data and press .  to stop \n");
 while(ch!='.')
 {
  ch=getchar();
  fputc(ch,fptr);
  }
  fclose(fptr);
  printf("\n now lets read the content from the file:");
  fptr=fopen("nellore.txt","r");
  while(!feof(fptr))
   printf("%c",getc(fptr));
  fclose(fptr);
}

------------------------------------------------------------------------------------
save as F_append.c
#include<stdio.h>
#include<conio.h>
//#include<process.h>

void main()
{
char ch;
FILE *fptr;
clrscr();
fptr=fopen("nellore.txt","r");
while(!feof(fptr))
{
 ch=fgetc(fptr);
 printf("%c",ch);
}
printf("\n what we saw till now is the content of file before appending\n");
fptr=fopen("nellore.txt","a");
if(fptr==NULL)
{
 printf("\n file cannot be be appended");
 exit(1);
}
printf("\n\n entestring to append:");
while(ch!='z')
{
 ch=getchar();
 fputc(ch,fptr);
}
 fclose(fptr);
 printf("\n \n content after appending is as follows:");
 fptr=fopen("nellore.txt","r");
while(!feof(fptr))
{
 ch=fgetc(fptr);
 printf("%c",ch);
}

 getch();
}


కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

100% C prog to write content into a file and then read it back onto the console

Spic macay

శ్రీరస్తు.. రామలింగ 18-1-24 (సూరసాని వారి ఆహ్వానము)