Terminal runs old code after new code saved


#1

I’m coding in C. My initial code used a printf string and GetInt to prompt user for a number, then i had a follow up printf string as a reply to user.
I deleted the follow up printf and saved many follow up iterations but when i ran the program from the terminal it continued to show the second, deleted follow up string. I ended up wiping the whole thing and starting over fresh but i’m worried i am doing something wrong that is going to screw with future programs i try to write.
Can anyone tell me what i did wrong or what is happening?


#2

There are two possible issues. either there was an error when saving the file, or there was an error compiling it so old code was running.
In the case of the first error ide should display red dot on the tab. You can check file contents on disk by using cat command in the terminal.
Diagnosing the second error depends on the runner you use. In which workspace did this happen?


#4

Hey there!
There was no issue with the save, or at least there was no indication (as in the red dot). I’m sorry that i don’t know what you mean by “which workspace”. I’m using the ide50 for cs50, if that’s what you were asking. It’s my first time using this system so forgive my ignorance.
thanks for the help!


#5

@cheberly603 just to be sure, as you didn’t explicitly state it in your first post;
When you’re saving followup iterations of the code, are you also running the make to recompile the code?

If you’re saving and trying to run, it will still only run the first piece of compiled code, regardless of how many changes you’re making to the source code.


#6

harveypoyntz:

Sorry, I should have been more specific. Yes, I was using ‘make’ to reconfig. So even after that when I ran the program it was outputting information no longer in the code. I’m assuming at this point it was a glitch or something.
Thank you!


#7

I had a very similar issue when I used more than 1 terminal to write and run code. That is to say, I had 2 instances of the IDE opened at one time. When I changed my code on a second terminal, the change was reflected in the first. When I shut down the second terminal, without even saving the code and I went back to the first terminal and did a Save and Make, it reported back that Make was up to date and did not recompile it. That is to say, when, in collaborative mode, a user changes code on one machine, yes the code changes on the other terminal, however, that other terminal does not note that the code has been changed, by the remote terminal, it thinks no changes were made. Thus it follows, when that terminal is asked to do another Save and Make, it thinks the user never changed anything and the last Make was OK therefore it refuses to compile again. It could be a bug in the Save feature too. Maybe if code is not changed by the local terminal, it saves the same code that was on the screen before the remote terminal changes it because it thinks there weren’t any changes at all.