Trying to reverse swap all the characters in a string array, however, it's not outputting right. Does anyone know if I'm heading the right direction?
My code:
#include <string>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <cstring> // for strlen()
using namespace std;
void doSwap (char &string1, char &string2) {
char temp;
temp = string1;
string1 = string2;
string2 = temp;
}
int main() {
string testingWord = "hello";
int i;
cout << testingWord << "\n";
cout << "\tBelow is testing the swap feature:\n";
for (i = 0; i < testingWord.size() - 1; i++) {
doSwap(testingWord[i], testingWord[i+1]);
}
cout << testingWord << "\n";
}
Here is my output:
elloh
Edit: Not trying to do XOR swapping?