I'm trying to set the variables char * vowels and char * consonants as the return value of the functions searchVowels and searchConsonants respectively.
Although when I test the code, the above variables are getting set properly but not being passed back into the main. And during a test with
cout << "text vowels" << vowels << "sametext" << consonants; ///something like this.
it doesn't display the consonant value now.
Here's my code, any suggestions would be super helpful. Except that I can't use strings.(For a class)
Also is this the appropriate way to post code?
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
const int SIZE = 7;
//This function greets the user.
void greetUser();
//This funcion asks for the array of letters.
char * inputLetters(char * inputArray);
//This will capitalize all letters to make them easier for the computer
//to compare.
char * capitalizeLetters(char * inputArray);
//This function will search the array for vowesl. If no vowels no game.
char * searchVowels(char * arrayCopy);
///This function will search the array for consonants.
char * searchConsonants(char * arrayCopy);
//This capitalizes all the letters in the initial array.
char * capitalizeLetters(char * inputArray)
{
for (int i = 0; i < 6; ++i)
{
inputArray[i] = toupper(inputArray[i]);
}
// inputArray = toupper(inputArray);
return inputArray;
}
//This program will search the array for consonants
//and return the consonants array.
char * searchConsonants(char * arrayCopy)
{
char * consonants; consonants = new char[SIZE];
for (int i = 0; i < 6; ++i)
{//I feel like I could make this into a function itself...hmm
if( arrayCopy[i] != 'A' && arrayCopy[i] != 'E'
&& arrayCopy[i] != 'I' && arrayCopy[i] != 'O' &&
arrayCopy[i] != 'U' && arrayCopy[i] != 'Y')
{
consonants[i] = arrayCopy[i];
}
}
return consonants;
}