473,666 Members | 2,010 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 4562
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
8953
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 to search any longer. Currently I am using this code. But I think it's too slow, because it runs through whole dimension. I know this is trivial question, but is there any way to stop this loop, or better way to search? I mean - FASTER?
2
3868
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 encoded using Base64. Dim username as String Dim pass as String Dim info_user as String info_user = username + ":" + pass
3
7662
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 error below. Can I access a Web Service through a Query Sting. I need to send XML to a Flash movie using a Web Service. Thank You, Jim Lewis Server Error in '/WebService1' Application.
24
17467
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 managed C++. It seems to work fine, but everyone knows that programs with errors can still appear to "work fine" :) I am working with VS .NET 2003; I am unable to upgrade to 2005 at this time, so I cannot use the newer syntax or features. ...
2
12826
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 position here ($10) but the text I extract is sometimes in a different position in the header so I need to search for preceding text "LINE:" and then extract the next string, which is the info I'm interested in. So - using awk or sed (or perl if need...
12
55914
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 BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ));
3
20069
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 keyword exists in the memo field and store that in a temporary table. My problem is the query to count the number of times the keyword is in the field.
8
13741
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 wrapper layers in unmanaged C++ and C#. I've thought about two approaches: 1) To pass a StringBuilder, this is converted to a char* in C++, the wrapper code converts the char* to a std::string (copy), and in the
2
3547
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. 1)Ex(String): The DOTNET is Very Cool! The Best. 2) Capture all the sequences like Spaces, Fullstops, Question Marks, Exclamations, Apostrophes, New Lines....(May be with RegEx?) 3)Split Words According to the above sequences 4)Get Distinct Words(Occurrences)...
0
8445
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.