scanf() can be used in this case, but it's a lot more work, because of the '.' and filename extension after it.
Eh? I see no reason why scanf() would be harder for those reasons. The %s specifier uses whitespace as a delimiter:
char filename[50];
if (scanf("%49s", filename) == 1) {
/* Yay! */
}
else {
/* Boo! */
}
However, modern operating systems allow embedded whitespace, and that's a good reason to avoid the %s specifier. Though you could use a scanset to read the full line:
char filename[50];
if (scanf("%49[^\n]", filename) == 1) {
/* Yay! */
}
else {
/* Boo! */
}
That said, I'd still recommend fgets(). ;)