-1

For some reason, I have a simple program that doesn't use files or anything. I have it saved as one name. "program2 working". I can compile and run this over and over no problems. However, if I go to change the file name (either "save as" from dev C++, copy it in it's folder to rename it, start a new project, copy the code, paste it and save as, etc) the code acts totally different. Like it won't print the picture it's supposed to print correctly for one function. It still works totally fine in the original file, but I can't change the name to submit it!

Any ideas on what could've happened?

user3866044
  • 181
  • 6
  • 20
  • 2
    i'm a bit unclear on what's happening. any code to show – Caffeinated Sep 16 '14 at 20:21
  • 1
    Depending on your dev environment, perhaps it has something to do with refactoring. I know with Eclipse, you can't just go changing filenames because the entire codebase is linked together. So, many references need to be updated to reflect the change. Thus the need to refactor. – durbnpoisn Sep 16 '14 at 20:23
  • Maybe the program depends on argv[0] – M.M Sep 16 '14 at 20:32

1 Answers1

-1

You cannot change the name without messing up the code. Why? Because when you compile the code, that name also gets carried along into the executable. So if you change the name you have a conflict

So you'll need to change class-name in the code, and re-compile

C++ compilation details

How does the compilation/linking process work?

Community
  • 1
  • 1
Caffeinated
  • 11,982
  • 40
  • 122
  • 216
  • 1
    It's a small "print the asterisk diamond" program. I should be able to open the cpp file and save it as another name and it should work just the same no? – user3866044 Sep 16 '14 at 20:27