Hansum
6 months ago

Stores a string to a variable using scanf in C

You can use "scanf("%d\n,variableName);" to store a string including the space to provide enough memory to the variable. ex:

char name[100];
printf("Enter a name);
scanf("%[^\n]",name);
printf("%s",name);
Do you have any comment on this tricks? then let the author know about that. comment here