I solved my problem.
firstly, I unistalled my current mingw compiler and use this compiler instead:
https://github.com/niXman/mingw-builds-binaries/releases/tag/13.2.0-rt_v11-rev1
from this page I downloaded x86_64-13.2.0-release-posix-seh-ucrt-rt_v11-rev1.7z this one. In this release of mingw in sec_api folder there is stdio_s header file in which freopen_s is defined.