Hello ladies and gents,
I'm trying to copy two words, for instance test and word into an array of characters and have this:
#include <iostream>
int main()
{
char word[10]= "";
char *wordArr[10];
for(size_t i = 0; i < 2; i++)
{
std::cin >> word;
*(wordArr + i) = word;
}
for(size_t i = 0; i < 2; i++)
std::cout << wordArr[i] << '\n';
std::cin.ignore(2);
return 0;
}
Thing is, it prints the last word twice as if it doesn't store the first word, what am I doing wrong, can anyone point me in the right direction?
I know I could use strings or even a vector, but, my idea is to work out a version using characters first, then strings and then a vector.