Yeah, I choose not to use
scanf() in most of my programs. Instead I use the
fgets() function and read from stdin like so:
Code:
#include <stdio.h>
int main(void)
{
char string[80];
printf("Enter a string: ");
fgets(string, sizeof(string), stdin);
printf("\n\nYou entered: %s");
return 0;
}
The only problem with
fgets() is that it captures the newline and includes it into your string. However, getting rid of that newline is simple. Good luck!