Exforsys
+ Reply to Thread
Results 1 to 3 of 3

Highlighting Vowel in a sentence

This is a discussion on Highlighting Vowel in a sentence within the C and C++ forums, part of the Programming Talk category; Help me, Write a function to return a nonzero if the character is a vowel (a,e,i,o,u - upper or lower ...

  1. #1
    dilah JD is offline Junior Member Array
    Join Date
    Feb 2010
    Answers
    2

    Unhappy Highlighting Vowel in a sentence

    Help me,

    Write a function to return a nonzero if the character is a vowel (a,e,i,o,u - upper or lower case), or zero if it is not a vowel. Test the function in a program that allows input of string - get() and a single character output - putchar() of the characters in the string with the vowels highlighted as shown.

    Example:
    Aloysius Washington

    <A>l<o>ys<i><u>s W<a>sh><i>ngt<o>n


  2. #2
    kiruthika_sri is offline Junior Member Array
    Join Date
    Feb 2010
    Answers
    4
    Code:
    #include<stdio.h>
    #include<string.h>
    main()
    {
            char c;
            char vowel[]="aeiou";
            while((c=getchar())!=EOF)
            {
                    if(strchr(vowel,tolower(c)))
                                    printf("<%c>",c);
                    else
                    printf("%c",c);
            }
    }



  3. #3
    dilah JD is offline Junior Member Array
    Join Date
    Feb 2010
    Answers
    2

    wow..

    wow..thats easyy~ haha..i did the code already and it sure is LONGGGG..

    while((c=getchar())!= EOF){ -----------line 1
    if(strchr(vowel,tolower(c))) {------line 2
    printf("<%c>",c);---------------line 3
    }

    Just wonderingg in the line 2 coding..

    strchr()? what actually the uses of it? cuz iv actually look in the internet, the result search was to point something and others were to find a character in a string? im not quite sure about it. It would be lovely if you can explain to me. (:

    anyway thanks for the coding..


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...