Skip to content

Instantly share code, notes, and snippets.

@Maxime66410
Created October 2, 2023 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maxime66410/c81aa7ff12c0943002f83daca8680bf5 to your computer and use it in GitHub Desktop.
Save Maxime66410/c81aa7ff12c0943002f83daca8680bf5 to your computer and use it in GitHub Desktop.
Simple User Information Input C++
#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