I'm trying to swap my chars in the char array so they would look like this: KO KO KO KO KO, however, the output isn't quite as what I expected: K OK OK OK OK
Any clue on what I am doing wrong?
#include <string>
#include <iostream>
using namespace std;
void swapIt (char &char1, char &char2) {
char temp;
temp = char1;
char1 = char2;
char2 = temp;
}
int main() {
char test[15] = "OK OK OK OK OK";
int x;
for (x = 0; x < 10; x++) {
swapIt(test[x], test[x+1]);
}
cout << test;
}
So clueless right now.
KO OK OK OK OK, thenK OOK OK OK OK, thenK OKO OK OK OK...etc.