Zmud -> C++

by Daganev

Back to The Real World.

Daganev2006-04-10 23:01:29
Anyone know how to convert the zmud code of

#if (@variable%ismember(@list)) { } { }

to a c++ equivilent?

I'd want the c++ to look like this..

if (word.substr(i,1).isMember(vowellist) { vowel++}
Unknown2006-04-10 23:42:53
EDIT: Adding comments, cause I need to practice making comments cause I never do!


#include ..............// String header
using namespace std;
string list;
string findstr;.................// Strings for the LIST you want to look through, and what you want to find
if (list.find(findstr,0) != string::npos) // returns the position of the first found, or string::npos if there are none... if its not string::npos, then it exists within the string.
{

}
Daganev2006-04-10 23:59:46
awesome, thanks.

Any ideas on why string.find() isn't in the appendix in my book?
Shorlen2006-04-11 00:07:22
QUOTE(daganev @ Apr 10 2006, 07:59 PM) 278055

awesome, thanks.

Any ideas on why string.find() isn't in the appendix in my book?


Because your book doesn't include the class that Dyr is using?
Unknown2006-04-11 00:09:42
ANSI strings
http://www.cppreference.com/cppstring/index.html

Google is my programing refrence book smile.gif.
Daganev2006-04-11 00:14:19
Its the same class... just a stupid book.

unfortuneatly, it doesn't look like this is going to work for me. I basically want to count how many vowels a string has, and didn't want to write word.substr(i,0) == "a" or word.substr(i,0) == "A" or word.substr(i,0) == "e" etc.... oh well.. thank you for your help.
Unknown2006-04-11 00:22:44
string.find_first_of("AaEeIiOoUuYy",0)

Tada!

For more info, the function is on the link I posted.

EDIT: I'm bored - find_first_of returns the first found postition of any character of the string, or string::npos if there are none.