Ok guys, so... im beginning to use this language and i have noticed that sometimes after u write a code, and then u write another one, when u run the program, it runs the old code, even if the new one is written on the screen, and i dont understand why this happens. For example, i wrote this code:
#include <iostream>
int main() {
std::cout << "What is your favorite numnber?" << std::endl;
int iNumber;
std::cin >> iNumber;
std::cout << "Your favorite number is " << iNumber << std::endl;
cin.ignore().get();
return 0;
}
But when i run the program, it runs it as if the first code was written on the screen, what could cause this, is this a common issue, and, how can i resolve it? Thx
I think it might just be that you are not compiling the new code rather just clicking the "run" button in which case your IDE runs the compiled version. Look for something like Build and Run or something along similar lines.
Maybe you should close your workspace each time you want to run a new code.If you run the first code and then press new it means that you include an new code in your workplace which runs at the moment.For example you can have a workplace with 3 different cpp files and your final work may need all these 3 files which may be connected to each other.
Multiple file projects are irrelevant, considering the example code he gave. I think (like thepedestrian already pointed out), that it's rather you mistaking with the IDE's functionality. Instead of "Run", press "Build and Run" or "Build" and then "Run".