Using the following code:
char *name = malloc(sizeof(char) + 256);
printf(\"What is your name? \");
scanf(\"%s\", name);
printf(\"Hello %s. Nice to meet y
If someone is still looking, here's what worked for me - to read an arbitrary length of string including spaces.
Thanks to many posters on the web for sharing this simple & elegant solution. If it works the credit goes to them but any errors are mine.
char *name;
scanf ("%m[^\n]s",&name);
printf ("%s\n",name);