Buffer Problem Maybe?

This is a discussion on Buffer Problem Maybe? within the C++ Programming forums, part of the General Programming Boards category; Code: void ReadString(string Text, int speed) { int Tet = Text.size(); int i = 0; for(i = 0;i < Tet;i++) ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    114

    Buffer Problem Maybe?

    Code:
    void ReadString(string Text, int speed)
    {
        int Tet = Text.size();
        int i = 0;
        for(i = 0;i < Tet;i++)
        {
           cout << Text[i];
           Sleep(speed);
           if(kbhit())
           {
               getch();
               speed = 1;
           }
        }
    }
    
    void ReadString(string Text, int speed, int times)
    {
        int Tet = Text.size();
        int i = 0;
        int x = 0;
        for(x = 0;x <times;x++)
        {
            for(i = 0;i < Tet;i++)
            {
               cout << Text[i];
               Sleep(speed);
               if(kbhit())
               {
                   getch();
                   speed = 1;
               }
            }
        }
    }
    void SetupPlayerArea() // Requires gotoxy //Windows.h //namespace std
    {
                gotoxy(0,20);
                SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xE5 );
                string Playerline = "--------------------------------------------------------------------------------";
                string Blanks =     "                                                                                ";
                ReadString(Playerline,0);
                ReadString(Blanks,0,4);
                ReadString(Playerline,0);
                gotoxy(0,0);
    }
    Now what this does is it makes the bottom of the screen yellow with hyphens through the top and bottom row. But whenever i use this it creates a row of yellow background below the bottom hyphen like
    HYPHEN LINE
    BLANK LINE
    BLANK LINE
    BLANK LINE
    BLANK LINE
    HYPHEN LINE
    BLANK LINE
    And i cant see why this is occuring :/. Also the hypen line is suppose to be the bottom of the console window cause ive set the window size to 800 x - 350 y and the buffer size to 80 x and 26 y
    Last edited by Nathan the noob; 07-23-2010 at 07:30 PM.
    Who needs a signature?

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    You may use windows functions to deal with console, this way you practice Win32 API and you will really know whats going on.

    BTW, to debug a code make assumptions about value of variables during execution and test them using a debugger. I values or states are not what they are supposed to be trace them back to when they are changed in a wrong way.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cout redirection problem
    By MrLucky in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2007, 12:11 PM
  2. clear buffer
    By justins in forum C Programming
    Replies: 5
    Last Post: 05-19-2007, 07:16 AM
  3. Replies: 15
    Last Post: 10-31-2005, 08:29 AM
  4. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 03:34 PM
  5. memory allocation problem....help..
    By CyC|OpS in forum C Programming
    Replies: 8
    Last Post: 10-18-2002, 10:26 AM

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