How to prevent c file from immediately closing when it is opened

I had been learning C for about 5 days. I discovered that the .exe program closed immediately after it was open. I searched for this. I got to know about getc(); getch(); getchar(); and system(pause);. This worked but the problem with the first three is that they allowed the user to type when the .exe file was run. The problem with the last one is that it works only with windows. So, my question is that how we can prevent the .exe file from closing as immediately after it is opened without allowing the user to type. Also, the answer should work with all the operating systems. Thanks in advance.