4. Write a program to read a text file “brijesh.txt “ count and display the number of alphanets present in it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<conio.h>
int main(void)
{
char str[80];
int l=0;
clrscr();
FILE *fp;
if((fp = fopen("brijesh.txt", "w"))==NULL) {
printf("Cannot open file.\n");
exit(1);
}
do {
printf("Enter a string :\n");
gets(str);
l=strlen(str);
printf("charecter lenth are\t%d\n",l);
strcat(str, "\n"); /* add a newline */
fputs(str, fp);
} while(*str!='\n');
return 0;
#include <stdlib.h>
#include <string.h>
#include<conio.h>
int main(void)
{
char str[80];
int l=0;
clrscr();
FILE *fp;
if((fp = fopen("brijesh.txt", "w"))==NULL) {
printf("Cannot open file.\n");
exit(1);
}
do {
printf("Enter a string :\n");
gets(str);
l=strlen(str);
printf("charecter lenth are\t%d\n",l);
strcat(str, "\n"); /* add a newline */
fputs(str, fp);
} while(*str!='\n');
return 0;
}
No comments
Post a Comment