3
Do a function:
strShift()
that receives a string with alphabet letters and returns a new string with letters replaced by their successors in the ASCII table. For example, "Ana" returns "Bob" and "Zaza" returns "{b[B".The function must return NULL if no memory is available.
I did:
char* strShift(char *s) {
int i;
int tam = strlen(s);
char* nova = (char*)malloc((tam + 1) * sizeof(char));
if (nova == NULL)
return NULL;
for (i = 0; i < tam; i++) {
nova = *(s + i + 1) ;
}
nova = '\0';
return nova;
}
I can’t figure out what else to do where I’m going wrong?
The exit gives me a lot of exclamation points.
Friend, pardon. I forgot to mention some other features that the exercise asked for. As for example the use of pointer arithmetic, my fault. However, I have already solved here with what you answered. Thank you very much and big hug!
– GratefullyDead