Jump to content

I'm having a problem with c++...


Recommended Posts

I pretty much started programming (I don't even know if I'm using the right words here :/) three days ago... So this is probably a really basic question. Yes, I have googled it... so yeah... I'm using Dev-C++ (I think it's called a compiler... Again, I don't really know much)... Whenever I compile and run my code, I get this:

 

34j809v.jpg

 

No matter what I say, It always does this. As long as there are no errors in what I typed, this will happen. It's been working fine up until a few hours ago. I don't know how to fix this :/ Also, whenever I highlight something, it covers it in a black box type thing instead of being able to see what you highlighted.

 

Again, I have virtually no programming experience, so all help will be appreciated and stuff :/ I don't even know if this is the right forum to ask this in :wall: Sorry if it's not :/

Link to comment
Share on other sites

Definitely seems like the right forum, always cool to see someone starting to program. What you will want to do though is really highlight your problem. From what I can tell, the output all makes sense. It's requesting a number, choosing a random power then displaying the output value of the number to that power, then stating what it did. I can't quite tell what it is that was working before, and yet isn't now.

 

Another thing that dramatically helps anyone looking to help is posting the source-code of the program. That way we can look through it and find the issue rather than guess-work. ;)

Link to comment
Share on other sites

Definitely seems like the right forum, always cool to see someone starting to program. What you will want to do though is really highlight your problem. From what I can tell, the output all makes sense. It's requesting a number, choosing a random power then displaying the output value of the number to that power, then stating what it did. I can't quite tell what it is that was working before, and yet isn't now.

 

Another thing that dramatically helps anyone looking to help is posting the source-code of the program. That way we can look through it and find the issue rather than guess-work. ;)

It doesn't matter what the source code is, it always does:

 

34j809v.jpg

 

 

As long as there are no errors in the source code, it will always run that program or whatever. I want it to do what I tell it to do :/

Link to comment
Share on other sites

I've not got much experience with Dev-C++, but from that my immediate question would be - are you recompiling the modified source-code and running the appropriate compiled executable to test it? It could well be you're running an old one and hence just getting the old results.

Link to comment
Share on other sites

I've not got much experience with Dev-C++, but from that my immediate question would be - are you recompiling the modified source-code and running the appropriate compiled executable to test it? It could well be you're running an old one and hence just getting the old results.

I just deleted all of the old code and typed something new. I don't really understand your question completely, but I'm pretty sure I was doing what you think I was doing...

 

 

 

I just started a new source file and it works now... :wall: Thanks for the help :P

Link to comment
Share on other sites

I just deleted all of the old code and typed something new. I don't really understand your question completely, but I'm pretty sure I was doing what you think I was doing...

 

I just started a new source file and it works now... :wall: Thanks for the help :P

Ah well, that's all good then! :)

 

C++ is a compiled language, in that the source-code that you write has to be compiled by the compiler into another form before it can be executed. In this case, it should compile it to an executable file. (From the image, "Junk[Caution: Executable File]") What this means is that whenever a change is made to the source-code, the code that you write, that needs to be re-compiled to form the executable that you run to actually launch the program.

 

However, as I'm not sure on Dev-C++ it could well be that that's all essentially done in the background without it being apparent, in a similar fashion to how most IDEs do it with Java, it still compiles but you don't need to do anything in the command-line sense. :)

Link to comment
Share on other sites

There is no longer a problem :P I don't think I explained it very well and I still can't :wall: No matter what I changed the source code to, it would still do that :wall:

 

Example:

 

#include <iostream>

 

int main()

{

using namespace std;

cout << "Hi" << endl;

system("pause");

return 0;

}

 

still gave me

 

34j809v.jpg

Link to comment
Share on other sites

Then you're not clicking the right executable. Either that or you changed the code and didn't compile.

 

The code you put here does something like:

208u3ox.png

Link to comment
Share on other sites

Then you're not clicking the right executable. Either that or you changed the code and didn't compile.

 

The code you put here does something like:

208u3ox.png

 

 

His problem was that his previous code was still loaded into the compiler buffer. Instead of running his new code, the compiler would use his old code. All he had to do was compile his new code before running it and it would've fixed his problem.

wii_wheaton.png

[software Engineer] -

[Ability Bar Suggestion] - [Gaming Enthusiast]

Link to comment
Share on other sites

Dev-C++ has an atrocious build system. Use Visual Studio 2010 Express or Code::Blocks; basically, anything else. Dev-C++ probably doesn't think your code is updated and doesn't rebuild.

ozXHe7P.png

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.