Understanding how vulnerabilities occur while accessing files in C

Let's assume that you wrote a program to create a text file named file1.txt. In such programs, a malicious user or hacker might add some soft links to some important or sensitive file in the file that you want to create. As a result, it will lead to overwriting of the important file.