I’m compiling a C file on Terminal on my mac, but when I run the a.out file, it will only compile an old version of my file.
For example, let’s say my C file is made to print out “Hello, World!”, I compile it using gcc and I run the a.out file, the a.out file will print out “Hello, World!”.
If I then change the C file to print out “Goodbye”, compile it and then run the a.out file, the Terminal will still print out “Hello, World”. Does anyone know how to fix this?
All I am typing into the Terminal is
gcc main.c
~/a.out
Which is all I should be inputting right?
Please let me know if I didn’t make anything clear enough.
Thanks!
You are typing in
Which means “run the
a.outprogram from the home directory.” I think you want to typeWhich means “run the
a.outprogram from the current directory.” If you are usinggcc, the newly-created program will be placed into the current directory (which, unless you’re in the home directory, is not the same place), so the new version will run the right program.Hope this helps!