I\'m trying to reverse an array and simultaneously store it in a new array with for loops. I have achieved it somewhat manually but not with loops. The first code b
for
You have two nested loops, and they are not doing what you think they are doing. You only need one:
int y, s; s = strlen(wrd) - 1; for (y = 0; y<=s; y++) { rev[y] = wrd[s - y]; }
and don't forget to terminate:
rev[s + 1] = 0;