I am extremely new to c++ and wrote this program to reverse a word. What I tried was to basically loop through an array and swap first letter with the last, second with the second last etc. However the result is some wired characters ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠Ω ⌠7p≈╗. I don't want a work-around since there are plenty of examples online. I just want to know why what I am doing wont work.
#include <iostream>
using namespace std;
int main()
{
char word[10];
for (int i = 0; i < 10; i++)
{
word[i] = word[sizeof(word - i)];
}
cout << word << endl;
return 0;
}
It is also giving me this warning warning C6001: using uninitialized memory 'word'. But I though I initialized the memory by doing char word[10].