main()
{
FILE *fp;
char c;
int nc=0,nw=0,nl=0;
fp=fopen("hello.txt","r"); /* hello.txt is already existing file */
if(fp==NULL)
{
printf("\n file does not exist");
}
while((c=getc(fp))!=EOF)
{
nc++;
if(c==' ')
nw++;
if(c=='\n')
nl++;
}
printf("\n number of characters=%d\n number of words=%d\n number of lines=%d",nc,nw,nl);
}
OUTPUT:
no of characters=25
no of words=7
no of lines=2
C lab sample programs
C program to create a file and display file contents on to the screen , file handling in c, random access to a file, random handling in file, random file handling in c, random access to a file in C, getc(), putc(), fopen(), fclose(),getw(),putw(), c program to display file contents on to the screen. different typed of modes in files. differentiate between r and r+ mode, w and w+ mode , a and a+ mode.EOF, end of the file.i Modi banned 500rs and 1000rs. new 500rs notes, new 1000rs note, new 2000 rupee note, new currency with chip enabled, 2000rs note with chip enabled.logic behind banning,hange, tax exemption on money, tax exemption on toll gate free, ATMS not wroking , firday new notes released , why 500 and 1000rs notes banned abdul kalam photo on 200rs n otes, tax on currency exc500 100rs notes clab sample programs
No comments:
Post a Comment