X
xeys_00
I'm trying to use the character "q" to exit this program. But if
anything but q is input , I want the loop to continue. Am I using the
wrong loop?
#include <string>
#include <iostream>
std::string first_name;
std::string last_name;
std::string full_name;
int i=0;
char quit='q';
int main()
{
first_name = "John";
last_name = "Doe";
full_name = first_name + " " + last_name;
std::cout << "Full name is " << full_name << "\n";
do {
std::cout << "What element of array do you want to see?";
std::cin >> i;
std::cout << "Value of i is " << full_name.at(i) << "\n";
std::cout << "Press q to quit. \n";
std::cin >> quit;
} while (quit!='q');
return (0);
}
anything but q is input , I want the loop to continue. Am I using the
wrong loop?
#include <string>
#include <iostream>
std::string first_name;
std::string last_name;
std::string full_name;
int i=0;
char quit='q';
int main()
{
first_name = "John";
last_name = "Doe";
full_name = first_name + " " + last_name;
std::cout << "Full name is " << full_name << "\n";
do {
std::cout << "What element of array do you want to see?";
std::cin >> i;
std::cout << "Value of i is " << full_name.at(i) << "\n";
std::cout << "Press q to quit. \n";
std::cin >> quit;
} while (quit!='q');
return (0);
}