473,508 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

count vowels from string using isvowel, how do get vowels from the string

4 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. bool isVowel(char);
  7.  
  8. int main ()
  9. {  
  10.    // Declare variables.
  11.    string word;
  12.    char ch;  
  13.    int numOfVowel = 0;  
  14.    int vowel; 
  15.  
  16.    // Get letters from the user. 
  17.    cout << "Please enter a sequence of letters: " << endl << ">";  
  18.    cin >> word; 
  19.    vowel = isVowel(ch);
  20.  
  21.    // Loop to grab all letters.
  22.    while (ch != '\n')  
  23.     {  
  24.        if (vowel == true) 
  25.        {     
  26.        numOfVowel++;  
  27.        cin.get(ch); 
  28.        }
  29.     }  
  30.    // Output statment to user with number of vowels found.
  31.    cout << "The number of vowels is sequence is: " << numOfVowel << endl;      
  32.  
  33.    system("pause");  
  34.    return 0;  
  35.  
  36.    // Function to find the vowels.
  37. }
  38. bool isVowel(char ch)
  39. {
  40.      if ('A' == ch || 'a' == ch ||'E' == ch || 'e' == ch ||'I' == ch ||
  41.          'i' == ch ||'O' == ch || 'o' == ch ||'U' == ch || 'u' == ch) 
  42.      {
  43.      return true;
  44.      }
  45.      else return false;        
  46.  
Oct 20 '11 #1
1 4554
johny10151981
1,059 Top Contributor
In C/C++ string array is null terminated, it means the string will be considered end if the default string processing functions found 0(integer zero, not character zero). If it dont find the 0 it will continue its process, and may cause segmentation fault.


Here is a simple method of how to access all the character individually in a string(char array)


Expand|Select|Wrap|Line Numbers
  1. for(i=0;a[i]!=0; i++)
  2. {
  3.  printf("%c",a[i]);
  4. }
  5.  
Oct 20 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
8947
by: Jozef Jarosciak | last post by:
Quickest way to find the string in 1 dimensional string array! I have a queue 1 dimensional array of strings called 'queue' and I need a fast way to search it. Once there is match, I don't need...
2
3829
by: Bruno | last post by:
Hello friends I'm creating one application that will send content to another app using HTTP connection. To authenticate my connection, I need to send a string with the username and password...
3
7642
by: Jim Lewis | last post by:
I have read several things that state accessing a Web Service through a Query String should work. However, when I try to execute http://localhost/webservice1/service1.asmx/HelloWorld I get the...
24
17436
by: Marcus Kwok | last post by:
Hello, I am working on cleaning up some code that I inherited and was wondering if there is anything wrong with my function. I am fairly proficient in standard C++ but I am pretty new to the .NET...
2
12819
by: Bryan_Cockrell | last post by:
Hi World, I am extracting text from an ebcdic header using dd in the cygwin environment (bash/ksh) as below in order to rename the file to something intelligent. I'm using a specific string...
12
55897
by: kishore314 | last post by:
Hi, Just a small excerise for me. A program that counts number of words in a string. The program which i have written now is - import java.io.*; class countword { private static...
3
20033
by: csgraham74 | last post by:
Hi Guys, I was wondering if soemone could help me. Im trying to write a piece of code that queries a field in ms access for a keyword. what i want to do is count the number of times the...
8
13714
by: Edson Manoel | last post by:
I have some C++ unmanaged code that takes std::string& arguments (as reference), and fills them (possibly growing the string). I want to call this code through PInvoke (DllImport), possibly using...
2
3533
by: DexterID | last post by:
Hi, I tried so much working with this to get distinct Words and their count. I'm using ASP.NET 2.0. And i also googled so much. I need HELP from anyone to get the required output. ...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.