using cs50's get_string function:
#include <cs50.h>
#inlcude <stdio.h>
int main(void)
{
String name = get_string("What is your name: \n");
printf("Hi %s\n" , name);
}
source: cs50