NEED HELP IN ARRAYS

I need help in arrays

i m editing a basic plugin of game in c++

if (message[0] == '@' || message[0] == '/' || message[0] == '!' || message[0] == '%' || equal (message, ""))

in above code messeage is input from player..
if player types '@hii' or '/me', message will not b displayed , bt if anyone types 'hii @ni' or 'say /me' then message will b displayed..

means if the first character of message is @,/,!,% message will not be displayed

bt i dont want it like that, i dont want to show those symbols anywhere in that message..

so i need to write it like this?

if (message[0] == '@' || message[1] == '@' || ............message[192] == '@')

size of array is 192..

plzz help me! :(

full coding is here..
http://shorttext.com/XqJAhV
Last edited on
closed account (28poGNh0)
Please put your file code here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
#include <algorithm>


struct remove_ignore
{
    static const std::string ignore;
    
    bool operator()( const char ch )
    {
        return this->ignore.find(ch) != std::string::npos;
    }
};

const std::string remove_ignore::ignore = "@/!%";

int main(void)
{
    std::string text = "say @you: 5% of 100 is 5! Check C:/my_math_book.pdf.";
    
    std::cout << "Before: " << text << '\n';
    
    auto new_end = std::remove_if( text.begin(), text.end(), remove_ignore());
    
    text.erase( new_end, text.end() );
    
    std::cout << "After : " << text << '\n';
    
    return 0;
}
Topic archived. No new replies allowed.