I have simply program to write. I try to make it with pointers. It is program which is changing uppercase to lowercase without index from function argument. Problem is with changing value, my program is crashing there...
#include <iostream>
#include <cstring>
using namespace std;
char* male(char* nap, int n) {
for (int i = 0; i < 9; ++i) {
if (i != n && ((*nap >= 'A') && (*nap <= 'Z'))) {
*nap = (char)(*nap+32);
}
nap++;
}
return nap;
}
int main() {
char * nap = "aBCDEFGHI";
male(nap, 2);
return 0;
}
Could you tell me why *nap = (char)(*nap+32);
is not a good way?