Using the OP's code exactly as posted and building it
as a C program, not C++, the debugger should complain
about an assertion: stream != nullptr
This occurs on the fputc because fp == NULL
After choosing Abort from the choices offered, the
program should exit and the Output window will show
that the program exited with code 3.
The interpretation I gave of that code is from:
System Error Codes (0-499)
https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
If I change the user name from what the OP posted to
my own user name and rebuild, the program then runs
correctly and creates the file on my desktop, exiting
with code 0 as expected.
- Wayne