WAP to remove vowel string using Pointer and Function
pls help
WAP to remove vowel string using Pointer and Function
pls help
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
First is to clarify the problem: remove vowel string? Do you mean to remove certain characters ('a', 'e', 'i', ...) from a string? If so, say exactly which characters. For example, is 'y' a vowel?
Next, as Salem mention, is to try something yourself and then ask for help on details.
For a second there, I thought we were inbound to the LZ: WAP, WAP, WAP, WAP,WAP.
Heres my code but it Did'nt Worked as ExpectedCode:#include<stdio.h> void remvow(char *); void main() { char str[20]; printf("Enter String :"); gets(str); remvow(str); } void remvow(char *t) {while(*t!='\0') {if(*t!='a'||*t!='e'||*t!='i'||*t!='o'||*t!='u') printf("%c",*t); t++;} }
Can anyone Figure out The Problem.
It is Compiling and Runing but not Removing Vowel
The logical OR operator is an 'inclusive' OR. So, if ANY of your expressions evaluates to true, the printf() is executed.
If you think about it, you need all of the expressions to be true simultaneously - therefore use the logical AND operator - &&.
Write it in English first
if not (is a vowel)
if not ('a' or 'e' or 'i' or 'o' or 'u')
Then convert it to C
Code:if(!(*t=='a'||*t=='e'||*t=='i'||*t=='o'||*t=='u'))