#include <stdio.h>
#include <stdlib.h>

void main()
{
    int i,j,n,c[10];
    char *str,ch;
    str=(char*)malloc(20);
    printf("enter the string: ");
    fgets(str,sizeof(str),stdin);
    n=strlen(str);
    printf("%d",n);
    j=1;
    c[1]=0;
    for(i=0;i<n;i++)
    {
        ch=tolower(str[i]);
        if(ch== '')
        {
            j++;
            c[j]=0;
        }
        if(ch=='a'||ch='e'||ch='i'||ch=='o'||ch=='u')
        c[j]++;
    }
    printf("no of vowels in each word in given line is \n");
    for(i=1;i<=j;i++)
    {
        printf("word is %d-->%d\n",i,c[i]);
    }


}

in this i have to count the number of vowels in each word the compiler say the error is at here at 18th line if(ch== '')

the compiler say the error is at here at 18th line if(ch== '')

There's no such thing as an empty character literal, the compiler is telling you that. I can only speculate about what you were trying to do, which is check for the end of a string? In that case you test for '\0'.

#include <stdio.h>
#include <stdlib.h>

void main()
{
    int i,j,n,c[10];
    char *str,ch;
    str=(char*)malloc(20);
    printf("enter the string: ");
    fgets(str,sizeof(str),stdin);
    n=strlen(str);
    printf("%d",n);
    j=1;
    c[1]=0;
    for(i=0;i<n;i++)
    {
        ch=tolower(str[i]);
        if(ch=='\0')
        {
            j++;
            c[j]=0;
        }
        if(ch=='\a'||ch='e'||ch='i'||ch=='o'||ch=='u')
        c[j]++;
    }
    printf("no of vowels in each word in given line is \n");
    for(i=1;i<=j;i++)
    {
        printf("word is %d-->%d\n",i,c[i]);
    }


}

error is at line 23 can i use ascii value of vowels???? instead of word .so compiler can easily understand space or anything

error is at line 23 can i use ascii value of vowels????

Two things:

  1. POST THE ERROR! You should make it as easy as possible to help you, and forcing us to either be a human compiler or copypasta your code into a compiler to see what the hell you're talking about is encouraging people to not help.

  2. Read your own errors. If you had taken the time to read the error and study your own code, you wouldn't have needed to ask for help. This is a very obvious error and a very common bug among beginners and experienced C programmers alike. You're using = instead of == for comparison.

@ line 23: use the == operator at the 2nd and 3rd condition, that's suppose to be ch == 'e' and ch == 'i'.
also did the program compiled without including the ctype and string libraries necessary for using tolower and strlen functions

also did the program compiled without including the ctype and string libraries necessary for using tolower and strlen functions

It's not good practice, but that's allowed except when the function being called uses variable parameters (like printf() or scanf()). If you're calling a variable parameter function then a declaration must be in scope or you invoke undefined behavior.

This question has already been answered. Start a new discussion instead.