You are here:
I can answer questions about C / C++ programming, software design, algorithms, and interprocess communication. I have access to Microsoft Visual Studio and gcc as my development platforms.
I have been developing software professionally for UNIX and Microsoft Windows since 1991.
I have a Bachelor of Applied Science in Computer Engineering from the University of Waterloo located in Waterloo, Ontario, Canada.
Every time I answer someone's question, I learn something new.
| User | Date | K | C | P | Comments |
|---|---|---|---|---|---|
| henry | 01/13/12 | 10 | 10 | 10 | He is ausome! simply the best |
| Stephane | 01/07/12 | 10 | 10 | 10 | |
| Stephane | 01/06/12 | 10 | 10 | 10 | Thank you, yet again good sir. :) |
| Stephane | 01/06/12 | 10 | 10 | 10 | |
| Stephane | 01/05/12 | 10 | 10 | 10 | Explains thoroughly and each point he brings ..... |
Hi Stephane You see the same value for infected because of this statement: infected = rand()<=Inv_NumofBees The expression: rand()<=Inv_NumofBees is a comparison, and a comparison is either
Every time you call rand() you get a new random number. I thought that was what you wanted. I guess you actually want the same number used throughout. Of course that makes sense. Save the value like this:
Hi Stephane You are getting random data in the file because you are not initializing the Inv_ variables. You should always initialize all your variables before using them. Don't assume that they start
Hi Stephane In the line which prints to the file you have: Inv_Money-price*numofbees price is a float, so the entire expression gets promoted to a float, but the formatting string in LINE_3 specifies
Hi Stephanie At this part: if (fscanf(file, LINE_1, &Numofbees) != 1) /*Checks for the number of bees and the amount of money he has.*/ (fscanf(file, LINE_3, &Money) != 1); { You have misplaced
Answers by Expert:

©2012 About.com, a part of The New York Times Company. All rights reserved.