Hi,
You should be compiling with
-Wall -Wextra -pedantic
Always compile with the highest warnings levels. Warnings are a good thing, they tell one about where a program might be going wrong :+)
Good Luck !!
Edit:
This might seem pedantic, but one has to be really careful with C.
Line 7 says that writing to the file was successful, but you have no idea whether that is true or not. All the
printf
and
scanf
functions return a value, so you should make use of that to see that it worked.
Consider using
snprintf
to print to a string first, if that works, use
fprintf
to print the string you just made, but still check to see it worked. A
switch
is handy to process the return values.
Maybe all this is too advanced right now, but at least you have an idea :+)