![]() |
| ||
| Function Back to Main Greetings: A simple question that has me stuck: Program runs, calls function, function runs... Return to Main? This last area is where it fails. No errors, just no control returned to Main.cpp at end of function run. I've been studying the code much and researching the solution on the Net all day. I swear there is one (1) too many "}" in Look.cpp, but it is not detected by the compiler. (?) Any point in the right direction would be vastly appreciated-- I do not want the answer given to me directly at this point, I want to figure it out myself. Perhaps just a hint, a link to a relevant Web resource, etc? Thank-you in advance, everyone. Look.h class Look {Main.cpp#include <iostream> Look.cpp #include <ctime> |
| ||
| Re: Functiom Back to Main The number of braces in printShipPos() looks ok to me. srand((unsigned)time(0)); //RNGtwo comments: (1) srand() should only be called once throught the lifetime of the program. Best place to put it is near the beginning of main() function. (2) I hope you realize that loop will be executed only once. If you do then there really is no point to the loop. |
| ||
| Re: Functiom Back to Main Ancient Dragon: Cool. I will move and edit the RNG like said. |
| ||
| Re: Functiom Back to Main two comments: (1) srand() should only be called once throught the lifetime of the program. Best place to put it is near the beginning of main() function.And, I can simply call this from within the program when needed, say from the area it originally was located? |
| ||
| Re: Functiom Back to Main >>And, I can simply call this from within the program when needed, say from the area it originally was located? As long as it only gets called ONCE. Every time it is called it will reseed the random number generator |
| ||
| Re: Functiom Back to Main Quote:
|
| ||
| Re: Function Back to Main Quote:
Finding the solution for this is not going so well. I always miss the little things and I think it is the same in this case; I made a copy of the project last night so I could hack at it freely and see what was going on-- this has yielded nothing as of yet. I have been debugging. This is always neat. It is one of my favorite aspects of programming, digging around step-by-step in hopes of unearthing a bug buried deep like an unwanted treasure. :) I guess I always took for granted the concept of returning control to Main-- this has never been an issue before. What am I missing? There must be a lesson here. One thing about programming that I love: there is always so much to learn. I am going to keep pushing forward with this problem. I could use some help and direction from any kind-hearted coder who has the time. Thank-you. |
| All times are GMT -4. The time now is 9:06 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC