If I have a string with 50 characters like
a = "ZfJt0\qVwy<aGWdkC5[HI[A2<ux1ajSI4I1OotE`uZo0ZErf0d"
How can I use c++ to delete the symbols from the string?
Only the characters a-z
and A-Z
can stay in the string, and all the others need to be removed. Using the example above the result has to be
"ZfJtqVwyaGWdkCHIAuxajSIIOotEuZoZErfd"
I have tried in the following way, but it doesn't work
for (int i = 0; i < a.length(); i++) {
if (!((int)a[i] > 64 && (int)a[i] < 91) || !((int)a[i] > 96 && (int)a[i] < 123)) {
for (int j = i; j < a.length(); j++) {
if (j == 49) {
a[j] = ' ';
} else {
a[j] = a[j + 1];
}
}
}
}