I tried editing other lines of code too, I just open vi, modify a print statement, and recompile (first deleting all .o and .exe of course). When I run it, the program fails to run its functions properly, and the print statement has not been changed. Then I simply type script, and suddenly everything runs perfectly and the printf statement is displayed properly. Then I exit the script, and once again the program misfires and displays the old print statement which has clearly been changed in vi.
This is the same problem I was having a few days ago, where all I was trying to do was create a simple helloworld app. It is apparently saving an old version of the code/executable and running that incorrectly (because it doesn't execute the old code properly at all) unless script is running, in which case it runs the new version correctly (in which only a single printf has been modified, and so there is no reason that the previous version wouldn't run properly as well).
I just can't imagine how this is happening when I am not recompiling anything, and all I am doing is turning script on and off.
One thing I noticed is that I have to exit script -twice-. The first time it says "There are stopped jobs." I don't know what that means but perhaps that is a clue.
Ok, this really blows my mind, but it proves there are two different programs stored in memory, and which one is called depends on whether or not script is active - I deleted everything in the folder, and the program STILL runs! It only fails to run if I call script, and then it acts as it should, because there is nothing to run. If I then disable script, the old program once again is called, and it runs albeit incorrectly and with old code.
Can you type "which c"? I can't imagine that you might have gotten some earlier version of your program installed in /usr/bin or somewhere in your path, but you never know.
Stop messing about with script and job suspension. That's where your trouble lies.
script basically opens up a shell within a shell. You can open script session while you have stopped jobs, but it won't let you exit the shell it created if you have stopped jobs. The instance of your chess program you started before you started your script session will be the one in memory before you made the changes, thus you wont see the changes when you return to the "outer" shell. You probably either ran the command with an & at the end, like "chess &" and put it in the background, or you hit ctrl-z to pause the job at some point. Either way, I think you have a giant clusterf--- of jobs and script sessions (hence my item #1 and 2 from post 13).
Type "jobs" at the terminal and see what comes up. It might be something like
Kill all of those. You kill by job number (the thing in [ ]), like so "kill %1". That kills job #1. Do that for all jobs, then exit that script with "exit" or ctrl-d. Keep doing this until all of your terminals close down and you're sitting at an empty desktop or login screen. Log in again in one terminal only. Do a "ps -f" to make sure you don't have any instances of your chess program running (you shouldn't if you actually logged out of all your shells/terminals). Your output should look similar to this:
+ Stopped ./a.out
Then, clean everything up, make your change, compile and run. Change it back, clean up, compile run. You should see the two different versions as you expect.
$ ps -fu username
UID PID PPID C STIME TTY TIME CMD
username 4582 4581 0 17:17 pts/4 00:00:00 bash -i
username 4649 4582 0 17:26 pts/4 00:00:00 ps -fu username
You don't by chance have a "debug" and "release" folder in there do you? You can wipe out the release folder as often as you like and it won't work for crap if the IDE is launching the debug version...
Originally Posted by Adam Rinkleff
Oooh... I thought ctrl-z exited? How do I exit then? I think you are right about the shell within a shell, at least its not a ghost within a shell. hah. hah.
Originally Posted by anduril462
........oh, ctrl-c, i always thought that was reserved for copying things.
Nah ctrl-z pauses the process. Notice how it says "stopped" if you type jobs.
Originally Posted by Adam Rinkleff
Also, in addition to killing them you can resume the process(es) either in the background with 'bg <num>' or in the foreground with 'fg <num>'
And yeah, ctrl-c usually means copy in GUI apps. But in console apps it means abort unless you explicitly override it to do something else.