like below fixes the issue argv contains an array of strings. Argv contains the program name, argv contains -f in your case, argv contains filename. If you print argv, you are printing the string starting at the third letter of -f. There is no such thing, so the behavior is undefined.
help you fix your problem There is no portable standard way to know what the types are. The first solution that comes to mind is to use the already well-known C idiom of having to pass a format string (e.g. printf, scanf).