Hello,
I encountered this problem and I was stuck for a days....
my problem is that when i change the
string Nickname; - into a char Nickname[10];
the compiler produces an error message.
*The objective of my program is to trim the characters
i mean i want to remove the #@$&*&*(&) ...etc
so example if the user will input a :
Nickname: J@n3
the compiler would just write the Nickname like this : Jn3
(I mean the purpose of my program is actually about file handling)
here's the code.
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 32
|
class account_query
{
private:
string firstName;
int total_Balance;
public:
void read_data();
void show_data();
void write_rec();
void read_rec();
void search_rec();
void edit_rec();
void delete_rec();
};
void account_query::read_data()
{
char chars[] = "!@#$%^&*()-_+=|\[{]}:;'`<>,?/`~";
cout << "Enter First Name: ";
cin >> firstName;
for (unsigned int i = 0; i < strlen(chars); ++i)
{
firstName.erase (std::remove(firstName.begin(), firstName.end(), chars[i]), firstName.end());
}
cout << "Enter Balance: ";
cin >> total_Balance;
cout << endl;
}
|
i think the problem is in here :
1 2 3 4 5 6
|
for (unsigned int i = 0; i < strlen(chars); ++i)
{
firstName.erase (std::remove(firstName.begin(), firstName.end(), chars[i]), firstName.end());
}
|
thanks... hoping for your help.