GIDForums

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-May-2008, 20:20
glen_4455 glen_4455 is offline
New Member
 
Join Date: May 2008
Posts: 1
glen_4455 is on a distinguished road
Unhappy

C++ code error


Hi all,

I am a new member here, I have some problem with my C++ code. I was trying to understand string programming. I was wondering if there anyone would be able to see through my codes and fix it up and explain to me as well.

CPP / C++ / C Code:
#include <iostream>
#include <string>
 
 
using namespace std;
 
    bool isVowel(char x);
    void Vowel(string x);
    void nonVowel(char begin, string end);
 
 
int main()
{
     string line;
     char ch;
     cout <<"Masukkan Nama anda : ";
     getline (cin,line);
     string word,notFirst,first;
     while (line.length()!=0)
{
     int wordlen = line.find(" ");
     if (wordlen >0)
{
     word = line.substr(0,wordlen);
first=word.substr(0,1);
ch = first[0];
string notFirst(word,1);
}
        if(isVowel(ch))
{
     Vowel(word);
}
        else
{
    nonVowel(ch,notFirst);
}
}
return 0;
}
 
 
bool isVowel(char x)
{
char low_case=tolower(x);
    if(low_case =='a')
     return true;
    else if (low_case =='e')
     return true;
    else if (low_case =='i')
     return true;
    else if (low_case =='o')
     return true;
    else if (low_case =='u')
     return true;
    else if (low_case =='y')
     return true;
    else
     return false;
}
 
void vowel (string x)
{
string newWord;
newWord = x + "way";
cout <<newWord<<endl;
}
 
void nonVowel(char begin, string end)
{
string newWord;
newWord = end + begin +"ay";
cout <<newWord<<endl;
}
Last edited by admin II : 09-May-2008 at 04:36. Reason: Please surround your C++ code with [cpp] your code [/cpp]
  #2  
Old 09-May-2008, 07:53
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 353
Peter_APIIT is on a distinguished road

Re: C++ code error


What wrong with this code ?
__________________
Linux is the best OS in the world.
 

Recent GIDBlogGoing to Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 10:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 20:30
Can enum have same name as class? crystalattice CPP / C++ Forum 3 08-Dec-2004 16:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:03.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.