I'm getting errors saying that Index and Input are undeclared identifiers. They are declared. Suggestions?
The idea is to create a functions to read a string and output the consonants.
Code:#include <iostream> #include <conio.h> #include <string> using namespace std; int main() { //Step01: Declare Memory Locations string Input; string StripVowels(string); //Step02: Initialize Memory Locations int Index = 0; //Step03: Do the Work //Step03a: Ask for the Characters cout << "Please enter characters: "; cin >> Input; cout << endl; //Step03b: Output consanants cout << StripVowels; //Step04: Wrap up and Exit cout << endl; getch(); return 0; } string StripVowels(string MyChar) { while(Index < Input.size()) { if(Input.substr(Index, 1) == "a"; Index++; else if(Input.substr(Index, 1) == "e"; Index++; else if(Input.substr(Index, 1) == "i"; Index++; else if(Input.substr(Index, 1) == "o"; Index++; else if(Input.substr(Index, 1) == "u"; Index++; else {cout << Input.subst(Index, 1) << endl; Index++; } } }



LinkBack URL
About LinkBacks



