What language are you after?
In C (and C++), you could do the following:
#include <stdio.h>
int main()
{
char name[32]; // We'll have a variable called "name" and can store up to 32 characters.
printf("What's your name?\n"); // Asking the user for their name.
printf(": "); // Showing a prompt.
scanf("%s", name); // Reading the name from the standard input.
printf("Why, nice to meet you, %s!\n", name); // Using the "name" just to verify all went well.
return 0; // The program terminates indicating no error.
}