Hello experts. Sorry for the very basic question. I have started C++ now but I dont have any coding knowledge even in my academics. So please bare with me.
I m practising C++ by watching youtube videos.
While I am doing same as he do, I cant change the value in the middle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
usingnamespace std;
int main()
{
string characterName = "Shiva";
int characterAge;
characterAge = 30;
cout << "This is my name " << characterName << endl;
cout << "My age " << characterAge << " years old" << endl;
characterName = "Santosh";
cout << characterName << " Love badminton" << endl;
cout << "At this age " << characterAge << " Can play easily." <<endl;
return 0;
}
It is unfortunately typical that users of Codeblocks must exit the IDE, then relaunch it before rebuilding.
It seems it doesn't "realize" it must re-link after changes to source code. It isn't every rebuild, either. Unknown what conditions may cause it, but it is widely reported.
Some traps to look out for.
- Check no previous version of your program is running - Windows won't let you overwrite a .exe if it's still running.
- You're actually saving the latest edit.
- You're compiling the latest edit.
- Check your build output log tabs to see if there are any missed error messages.
- You're running the version you compiled - watch out for compiling debug and running release say.
- Your anti-virus s/w isn't quarantining any new version of the .exe you create. Consider adding an 'exclude directory' rule to your AV s/w which excludes your entire development tree.
- Quit and restart C::B. Sometimes, it just ties itself up in a knot.
$ cat foo.cpp
#include <iostream>
usingnamespace std;
int main()
{
string characterName = "Shiva";
int characterAge;
characterAge = 30;
cout << "This is my name " << characterName << endl;
cout << "My age " << characterAge << " years old" << endl;
characterName = "Santosh";
cout << characterName << " Love badminton" << endl;
cout << "At this age " << characterAge << " Can play easily." <<endl;
return 0;
}
$ g++ foo.cpp
$ ./a.out
This is my name Shiva
My age 30 years old
Santosh Love badminton
At this age 30 Can play easily.
similar issues on other compilers, where the compiler can't tell that you modified code and keeps the old version to save time compiling. Most have a rebuild all that forces it to all work right, so you don't have to restart/exit but keep it in the back of your mind.