Sounds easy, but I’ve got a bug and I’m not sure what’s causing it?
nopunccount = 0;
char *ra = new char[sizeof(npa)];
while (nopunccount <= strlen(npa)) {
ra[nopunccount] = npa[strlen(npa) - nopunccount];
nopunccount++;
}
ra never gets a value into it and I have verified that npa has char values to provide within the nopunccount range.
Any help is appreciated // 🙂
nopunccountstarts as 0, so in the first iteration of the loop the character assigned tora[0]isnpa[strlen(npa)]. This is the terminating'\0'of that string. So the resulting string inrastarts with a'\0'and is therefore considered to be ending at that first byte by the usual string functions.