1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Filing Help In C Language

Discussion in 'Meet and Greet' started by global956, Nov 27, 2010.

  1. global956

    global956 New Member

    Joined:
    Nov 27, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    // A program to read a file and check how many vowels, spaces and consonents are there in a file
    My Questions:

    // A program to read a file and check how many words are there in a file


    // A program to read a file and check how many characters are there in a file

    can anyone solve these questions using below program.Please help me i am new in this form.
    Code:
    # include <stdio.h>
    # include <conio.h>
    # include <stdlib.h>
    
    void main ()
    
    { clrscr();
    char ch;
    FILE *fptr;
    int a = 0,e = 0,i = 0,o = 0,u = 0,c = 0,s=0,sum ;
    if ((fptr = fopen("jawwad.txt","r"))== NULL)
    {
    printf("Can't open the file");
    getch();
    exit(1);}
    
    while ((ch =getc(fptr))!= EOF){
    printf("%c",ch);
    switch(ch)
    {
    case 'a':
    a++; break;
    
    case 'e':
    e++; break;
    case 'i':
    i++; break;
    case 'o':
    o++; break;
    case 'u':
    u++; break;
    case '':
    s++;break;
    default:
    c++;
    
    }
    }
    printf(" \na=%d, \ne=%d, \ni=%d, \no=%d, \nu=%d, \ns=%d, \nc=%d",a,e,i,o,u,s,c);
    {
    sum=a+e+i+o+u+s+c;
    printf("\nThe sum is %d",sum);
    }
    fclose(fptr);
    getch();
    }
    
    
    My Questions:

    // A program to read a file and check how many words are there in a file


    // A program to read a file and check how many characters are there in a file

    can anyone solve these questions using above program
     
    Last edited by a moderator: Nov 27, 2010

Share This Page