Created
October 2, 2023 14:47
-
-
Save Maxime66410/c81aa7ff12c0943002f83daca8680bf5 to your computer and use it in GitHub Desktop.
Simple User Information Input C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.data.json.h> | |
using namespace std; | |
int main(int argc, char* argv[]) | |
{ | |
// Global design of console | |
system("color 0a"); | |
SetConsoleOutputCP(CP_UTF8); | |
SetConsoleCP(CP_UTF8); | |
string BorderDesign = "====================================="; | |
// User information | |
char name[50]; | |
int age; | |
string email; | |
string phone; | |
// Get user information | |
cout << BorderDesign << endl; | |
cout << "Enter your name: "; | |
cin >> name; cin.ignore(); | |
cout << "Enter your age: "; | |
// Enter only Integer on Age | |
while (!(cin >> age)) | |
{ | |
cout << "Please enter only Interger (Number): "; | |
cin.clear(); | |
cin.ignore(123, '\n'); | |
} | |
cout << "Enter your email: "; | |
cin >> email; cin.ignore(); | |
// Enter Email with @ | |
while (email.find('@') == string::npos) | |
{ | |
cout << "Please enter your email with @: "; | |
cin.clear(); | |
cin.ignore(123, '\n'); | |
cin >> email; | |
} | |
cout << "Enter your phone: "; | |
cin >> phone; cin.ignore(); | |
cout << BorderDesign << endl; | |
// Clear console | |
system("cls"); | |
system("color 0e"); | |
// Print user information | |
cout << BorderDesign << endl; | |
cout << u8"Your name is " << name << endl; | |
cout << "Your age is " << age << endl; | |
cout << "Your email is " << email << endl; | |
cout << "Your phone is " << phone << endl; | |
cout << BorderDesign << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment