When you use the array like this:
Code:
output[40] = collect();
output[40] = encrypt(output);
it should be
Code:
output = collect();
output = encrypt(output);
because in the first example, you are just telling it that the character at 39 in "output" should equal what collect does, it doesn't leave you with a string like you want.
And the collect and encrypt functions should look like this:
Code:
char *collect(void)
{
char word[40];
std::cout << "Input your word.\n";
std::cin >> word;
return (word);
}
char *encrypt(char word[40])
{
int index;
for(index = 0; index <= 40; index++)
{
word[index]++;
if(!word[index])
{
break;
}
}
return (word);
}
Because you want to return a pointer to a character instead of just one character, the former will be your string.