Working on High Scores...

This is a discussion on Working on High Scores... within the C++ Programming forums, part of the General Programming Boards category; I'm working on a function that seeks out where a high score should go in a text file. For some ...

  1. #1
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40

    Working on High Scores...

    I'm working on a function that seeks out where a high score should go in a text file. For some reason it loops until it gets to the highest number in the list. Here is the contents of "data.txt" and the problem code:

    800
    Greg
    700
    Suzy
    600
    George
    500
    Fred
    400
    Frank
    300
    Bob

    Code:
    void putit(){
    
    	int i=1;
    	int b=1;
             money=550;
    
    	while(money>=lowest){
    
    		File.seekg(ios::beg);
    
    		while(i<numberOfLines-b){
    			File.getline(TempInLine,256);
    			i++;
    		}
    
    		b+=2;
    		File>>lowest;
    
    	}
    }
    I just know it's something stupid but I've gone thru it too many times and just cannot figure it out. The problem is that "lowest" always is equal to 800 (the highest number in the list) no matter what the value of "money" is. Thanks for any help!
    - Grady (:

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    what is the value of lowest when it first starts?
    nextus, the samurai warrior

  3. #3
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40
    This function finds the lowest number and I run it before I run putit().

    Code:
     void lowestnumber(){
    	
    	int i=1;
    	File.seekg(ios::beg);
    
    	
    	while(i<oflines-1){
    
    		File.getline(input,256);
    		i++;
    	}
    	File>>lowest;
    
    
    		
    }
    So... the value of lowest is 300 before putit() starts.
    - Grady (:

  4. #4
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40
    I'm doing the high scores by myself. If anyone has any tips on how to do high scores more efficiently, please help me out. Maybe a different format of the text file or something...
    - Grady (:

  5. #5
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40
    I figured it out, if anyone was working on it. The problem is that "i" is never reset back to 1 in the loop. Thanks for all the help guys!
    - Grady (:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Solitaire High Scores
    By sean in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-03-2005, 08:15 PM
  2. High Score Not Working...
    By pbjorge12 in forum C++ Programming
    Replies: 4
    Last Post: 01-25-2005, 01:17 AM
  3. Dev C++ |Random Coding| Not Working!
    By oobootsy1 in forum C++ Programming
    Replies: 6
    Last Post: 03-05-2004, 10:13 PM
  4. Store high scores in exe file
    By Nutshell in forum Game Programming
    Replies: 12
    Last Post: 04-27-2003, 05:09 PM
  5. Help on high scores
    By Gnoober in forum C++ Programming
    Replies: 0
    Last Post: 02-17-2003, 07:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21