I am trying to write a program in "c" language that accepts file as input and prints only those lines of the file, that contains at least one vowel.
I have written the code so far as
Please guide me as to how to proceed with the same as it an interesting but complicated question. A code snippet for the later part would be much appreciated.
I have written the code so far as
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
FILE *fp;
char ch[100];
char chn[50];
int chk=0;
char *line;
char *name;
clrscr();
printf("\n Enter the name of the file: ");
scanf("%s", name);
fp =fopen(name,"w");
if(ferror(fp))
{
printf("\n Error opening file: ");
getch();
exit(1);
}
/* ENTERING TEXTS INTO THE FILE */
/*------------------------------*/
printf("\n Enter a few line of texts :");
printf("\n Enter $ to exit :");
while(strlen(gets(ch))>0)
{
if(ch=="$")
break;
else
{
fputs(ch, fp);
fputs("\n",fp);
}
}
fclose(fp);
/*---* Now to look for vowels per line *----*/
/*------------------------------------------*/
fp= fopen(name,"r");
while(!feof(fp))
{
while(chn!='\n')
{
if(chn='a'|chn='A'|chn='e'|chn='E'|chn='i'|chn='I'|chn='o'|chn='O'|chn='u'|chn='U')
{
/*stat[chk]++;*/
chk++;
line=
}
/*--------------- i am not sure what to do here ----*/
fclose(fp);
getch();
}
Comment