FREE : [ Study Material ] NDA/SSB Preparation : Check Now!!! | Latest: HR Interview Questions:CHECK | Like Us :

Wednesday 5 June 2013

WRITE A C PROGRAM TO OPEN A FILE AND DISPLAY ITS CONTENT along with the Number of Blanks,Characters and Tab

0 comments
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
int not=0,nob=0,noc=0;
fp=fopen("PRIME.C","r");
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
noc++;
if(ch==' ')
nob++;
if(ch=='\n')
not++;
if(ch=='\t')
not++;
}
fclose(fp);
printf("\nCharacters %d",noc);
printf("\nBlanks %d",nob);
printf("\nTABS %d",not);
printf("\n");
fclose(fp);
getch();
}


OUTPUT

Write a C program to open a File and display its content?

0 comments
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
fp=fopen("PRIME.C","r");
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
printf("%c",ch);
}
printf("\n");
fclose(fp);
getch();
}

Output:-



 

Results

get our extension

Like Us on FB

    Freshers Jobs

    Donate

    DMCA Protected

    You are Visitor Number

    Interview Questions

    SSB Questions

      Authors
    Tinku Singh
    Hitesh Dhanda

    MrNaukri.com - Get Sarkari Jobs, Results, Off Campus Placement Updates © 2012. All Rights Reserved | Back To Top |

    © 2013 A Product of IBC Network