How do I instead of entering a name, enters 'quit' and it will close the program?
string name;
cout << "Enter a name: "<< " ";
std::getline (std::cin,input);
input[0] = toupper (input[0]);
How do I instead of entering a name, enters 'quit' and it will close the program?
string name;
cout << "Enter a name: "<< " ";
std::getline (std::cin,input);
input[0] = toupper (input[0]);
C++ is rusty something like this...
string name;
cout << "Enter a name: "<< " ";
std::getline (std::cin,input);
input[0] = toupper (input[0]);
if (input[0] == 'quit')
{
std::exit;
}
Using Visual C++
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string strinput;
while (strinput != "quit")
{
cout << "Enter a name: " << endl;
cin.clear();
cin >> strinput;
if(strinput =="quit")
exit(0);
}
return 0;
}