Write an x64 MASM program using ReadConsoleA and WriteConsoleA to prompt the user for their name. The program should then display the user's name surrounded by asterisks. Allow the name to be up to 30 characters long. Example (user input is boldface, and there are 28 asterisks on the top and bottom lines): What is your name?

Respuesta :

Solution:

The following program will be run using Read Console A and Write Console A and it also displays the name of the user surrounded by asterisks

# include <iostream>

# include <cstring>

using namespace std;

int main(){

               char name[31];

               cout <<"What is your name? ";

               cin.getline(name,30,'\n');

               for(int i=1; i<=30 ; i++){

                               cout<<"*";

               }

               int spaces = 30 - strlen(name)-1;

               cout<<endl<<"*"<<name;

               for(int space=1; space<spaces; space++){

                               cout<<" ";

               }

               cout<<"*"<<endl;

               for(int i=1; i<=30 ; i++){

                               cout<<"*";

               }

              return 0

}