- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
12 Posted Topics
You gave yourself the answer there... IF the range is 0, then it doesn't have to guess any more. Looking at your original code, at line 23, you compute the range. After computing, test the range. If it is not 0, do what you have coded (this is in the …
Line 57 is probably causing some issues for you here. The end() method returns an iterator that points 1 position past the end of the vector. 1 position isn't the same as the integer 1. There is some danger in doing this, so I would probably look at how to …
I believe you are having this problem because the code is trying to go through the file two times. Line 33 starts a loop that goes through the input file all the way to the end of the file. Since you are now at the end of the file, line …
I agree with pseudorandom21 on the coding, but yes, you can do it your way. I'm not sure what your intention is with the code on line 27 in your adjusted code. After you print out that the password is incorrect, why not just return?
Have you thought about using vectors? If the array in question is small, can you create a copy with only the values you want to use?
Your example doesn't seem to give enough information to answer this. Your first set of code has a loop using w, but the loop is not acting differently between iterations (probably something in your comment for "some lines of code.") It seems that you would use the same value as …
Along the lines of what thelamb said... Make the loop more dynamic... Instead of while(true) <-- always true use a variable that you can change: [CODE] bool connected = false; while(!connected){ ... // when first connection made, set connected to true; connected = true; } [/CODE]
Yes, since the enum has defined a new type, you cannot say shipCost = BOMBER_COST; It would be equivalent to saying something like int = 25. In both cases you need to define a variable of that type and then set the variable to the value required: shipCost MyShipCost = …
Think of the process going on a stack. When your code enters somefunction, the if statement is checked and when true, it immediately calls somefunction again (not executing the cout statement yet.) All of these function calls are placed on a stack until the somefunction actually returns so you end …
I'm not sure I'm following the intent of this very well. The reason for the error is that the compiler cannot use a pointer as a physical location for storage of an int. The function Map::getTile() looks like it's really returning a pointer to a Tile and this is probably …
There are a few problems with the code you have posted. 1) In your main, where you call the functions, you are actually calling them twice. The first time on a line by itself, and then again in the cout statement (so, lines 41 and 47 could be commented out.) …
The End.
djarn