How to enter 'quit' to close program? -
how instead of entering name, enters 'quit' , close program?
string name; cout << "enter name: "<< " "; std::getline (std::cin,input); input[0] = toupper (input[0]);
c++ rusty this...
string name; cout << "enter 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 name: " << endl; cin.clear(); cin >> strinput; if(strinput =="quit") exit(0); } return 0; }
Comments
Post a Comment