Append a validated record without erasing prior records

Write a program reading one attendance record from stdin as id name present. Numeric input tokens are representable as int; id must be 1..9999 and present must be 0 or 1. A valid name is a single token of 1..15 ASCII letters; input name tokens obey this lexical/length contract. Validate numeric fields and conversions before opening attendance.txt. Append exactly "id name present\n", creating the file if absent; print appended only after fprintf and fclose succeed. For initial file "1 Ana 1\n" and input "2 Bo 0\n", give exact final contents. Explain why this simple file format cannot represent a name containing a space.


