the code is supposed to take 1-10 char word and copy the word into another array.
it somewhat does that but some mysteries are included
#include <iostream>
using namespace std;
int main()
{
char word[10];
cin>> word;
char *Arr;
int index=0;
for (int i=0; i<10; i++)
if (word[i] >= 'a' and word[i] <= 'z')
{
index++;
Arr=new char[index];
Arr[index] =word[i];
cout<< Arr[index]; //here it works somewhat fine except adding an extra 'x' at the end
}
cout<< endl;
for (int j=0; j<index; j++) //here it puts symbols
cout<< Arr[j];
return 0;
}
1) why does it add an 'x'?
2) why does it write other symbols when i try to view what is the word outside the first cycle?