How To Read Input Line Separated With Spaces To Store User Address C++ Windows Console Application Programming
How To Read Input Line Separated With Spaces To Store User Address C++ Windows Console Application Programming
This is a C++ Windows Console Application That allows user to enter details in a console and eventually display the entered data.
SOURCE CODE
#include <iostream> #include <string> int main() { std::string emailAddress{}, computerTyp{}, address{}; std::cout << "ITSx IT Solutions\n\nenter e-mail address :\n"; if (!getline(std::cin, emailAddress)) return 1; std::cout << "enter address :\n"; if (!getline(std::cin, address)) return 1; std::cout << "Enter the computer type :\n"; if (!getline(std::cin, computerTyp)) return 1; std::cout << "\nEmail Address : " << emailAddress << "\nAddress : " << address << "\nComputer Type : " << computerTyp << '\n'; }
VISUAL STUDIO 2019 OUTPUT
ITSx IT Solutions
enter e-mail address :
JANE@GMAIL.COM
enter address :
LOS ANGELES 123 ST.
Enter the computer type :
GAMING MSI COMPUTER
Email Address : JANE@GMAIL.COM
Address : LOS ANGELES 123 ST.
Computer Type : GAMING MSI COMPUTER
C:\Users\Win 10\Desktop\ITSx ConsoleApplication C++\Debug\ITSx ConsoleApplication C++.exe (process 8416) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
OUTPUT SCREENSHOTS
