Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ strings

Name: Anonymous 2010-11-26 9:22

Hey /prog/,

I need your help. I'm a beginner in C++ and I've been doing some exercises. I got stuck when asked to find a word made only with vowels. So far my program can find all vowels in the text but I've no idea how check if a word consists only of vowels.
I'm working with STL strings. I've tried google but everything's too confusing to me atm.

Please help.

Name: Anonymous 2010-11-26 9:23

The D Programming Language

Name: Anonymous 2010-11-26 9:25

int i;
char allVowels = 1;
for(i = 0; i < strLength; ++i){
    if(! isVowel(str[i])){
        allVowels = 0;
        break;
    }
}
if(allVowels){
    //do whatever
}


STRINGS? WHAT ARE THESE STRINGS YOU SPEAK OF?

Name: Anonymous 2010-11-26 9:27

>>3
Using char instead of _Bool or int.
IHBT.

Name: Anonymous 2010-11-26 9:30

>>4
why would i use 4 bytes when i can use 1?
and bool? lol, this is C, not java.

Name: Anonymous 2010-11-26 9:34

OP here.
Maybe this will help:
void FindWord (string S) {

    string word;
    string::size_type start(0);
    string::size_type end;
    end = S.find_first_of(Cdelim, start);

    while(end != string::npos) {
        word = S.substr(start, end - start);
        CheckWord(word);
        start = end + 1;
        end = S.find_first_of(Cdelim, start);
    }
    word = S.substr(start);
    CheckWord(word);
}

void CheckWord (string Z) {
    size_t found;
    string word;
    found = Z.find_first_of(Cvowels);
    while(found != string::npos) {
        word = Z[found];
        found = Z.find_first_of(Cvowels, found+1);
     }
    cout << word ;
    cout << endl;
}

Name: Anonymous 2010-11-26 9:50

>>5
Don't come crying to me when your critical loops are slow as molasses

Name: Anonymous 2010-11-26 10:10

int f(char *s) { return !s[strspn(s, "aeiou")]; }

Name: Anonymous 2010-11-26 10:43

>>7
>critical loops
>OP is clearly doing simple string exercises

YHBT

Name: Anonymous 2010-11-26 10:45

>>9

No sage, incorrect invocation of the quote environment, I think this guy might be from the imageboards.

Name: Anonymous 2010-11-26 10:47

>>10
i am not a bbcode master

Name: Anonymous 2010-11-26 11:09

>>11

Hint: It's not BBCode.

Name: Anonymous 2010-11-26 11:34

>>1
:3 mfw I realise that innocent soul of OP is currently being corrupted by C++ strings. No \b[aoieu]+\b regexpes for him! :3:3:3

>>10
Let's fork(2) him.

Name: Anonymous 2010-11-26 11:42

>>13

It's still obvious that you're from the imageboards.

Name: Anonymous 2010-11-26 11:56

>>3
Have I mentioned that I advertise on /b/ only with the purpose of giving you something todo?

Name: Anonymous 2010-11-26 11:57

>>14

>>11 =/= >>13
fyi

Name: Anonymous 2010-11-26 12:00

>>16
Faggot != detected.

Name: Anonymous 2010-11-26 12:02

>>17
thank you

Name: Anonymous 2010-11-26 12:40

>>14
your still a faggot

Name: Anonymous 2010-11-26 12:41


bool all_bowels(string::const_iterator start, end) {
  return (start == end) ? true :
         aintvowel(*start) ? false :
         allbowels(s, ++start);}


Doesn't work? Who cares, it's Sepples.

Name: Anonymous 2010-11-26 13:26

main = interact $ unlines . filter (all (`elem` "aeiouAEIOU")) . words

Name: Anonymous 2010-11-26 14:31

>>19
you're*

Name: Anonymous 2010-12-17 1:37

Erika once told me that Xarn is a bad boyfriend

Name: Anonymous 2010-12-25 11:45

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List