// This code should run
// When I run the code, I get the prompt to enter a number then when I press enter it crashes. File.exe stopped working or
// Unhandled exception at 0x0FBFE541 (msvcr120d.dll) in File.exe: 0xC0000005: Access violation writing location 0x00000000.
#include<stdio.h>
#include<conio.h>
void main()
{
int n = 0;
FILE *f;
fopen_s(&f, "text.txt", "r+");
if (f == NULL)
printf_s("Error!");
printf_s("Enter a number: ");
scanf_s("%d", n);
fprintf_s(f, "%d", n);
fclose(f);
_getch();
}