| home56 (3) | |
|
Good evening everyone. I'm in a beginning c++ programming class and we've been given an assignment. I understand that this site doesn't to the programming for me and I'm cool with that. I've research this forum as well as others and I believe that I'm close to a solution, but not quite there. Task: copy a given array of length 20 into another array of length 20 but in reverse order from the original array. This is a void function. Here is my code. I'd greatly appreciate any feedback. We haven't learned anything about a library function of copy_backwards or of vectors so this is a very basic program. void reverse Word(char word [], char reverse [], int howMany) { for (int i = howMany -1; i>=0; i--) for (int j=0; j<howMany; j++) reverse[j] = word[i]; return; } I'm copying only the last letter of the original array so my for loops aren't working. Thanks for your time. | |
|
|
|
| Arthur McKenzie (7) | |
|
Why have you got 2 loops? If you imagine two rows of boxes and each row consists of 20 boxes then you are well on the way to seeing why I ask | |
|
Last edited on
|
|
| yang (33) | |||
| |||
|
|
|||
| Arthur McKenzie (7) | |||
You only need one loop parameter
| |||
|
Last edited on
|
|||
| Bazzy (6275) | |
| reverse Word isn't a valid name, use reverse_Word or reverseWord instead | |
|
|
|