Originally Posted by
elad
Other examples:
...
I tried many different ways of making this while, but didn't manage to get it working, accept for this last one you provided. I now got this part:
Code:
char badwords[20][20];
ifstream file_bwchk ("badwords.txt");
char temp[20];
strcpy (temp, chattext);
int i = 0;
cout << temp << endl;
while(file_bwchk >> temp) {
for(i = 0; i < 20; ++i) {
if(strncmp(temp, badwords[i]) == 0) {
cout << "Naughty, naughty" << endl;
}
}
}
This one gives me this error:
/usr/include/string.h:100: error: too few arguments to function `int
strncmp(const char*, const char*, unsigned int)'
Just adding an int there won't help.. I guess I have to use that last int somewhere, but I can't exactly figure out where. When not using that int anymore than in the required line the console returns "Naughty, naughty" all the time, also when saying "test" or something like that.
Do you know how I have to use that extra int?
Originally Posted by
Rashakil Fol
I recommend at least converting characters to lowercase before comparing them. This should at least stop the idiots who curse because it's thrilling or something, without disrupting the "geniunely profane."
You're correct.. I didn't checked that
I searched on this site, other c++ sites, google and more, but provided examples didn't get me further than making text like "TEST" translating to "tEST" or "tEsT"...
This is where I make the variable:
Code:
char chattext[256];
char chatname[256];
strcpy (chattext, aw_string (AW_CHAT_MESSAGE));
strcpy (chatname, aw_string (AW_AVATAR_NAME));
And with these two methods (the only two I got working without errors):
["tEST"]
Code:
if (strcmp (chattext,"TEST") == 0) {
printf ("Before conversion: %s\n", chattext);
*chattext = tolower(*chattext);
printf ("After conversion: %s\n", chattext);
}
"tEsT"
Code:
if (strcmp (chattext,"TEST") == 0) {
printf ("Before conversion: %s\n", chattext);
for (char *iter = chattext; *iter != '\0'; ++iter) {
*iter = tolower(*iter);
++iter;
}
printf ("After conversion: %s\n", chattext);
}
But they but don't fulle lowercase the whole word.. Is there something wrong with the translation process, or do I use the wrong type of variable?