1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Overwritting Text in C++ (with cout)

Discussion in 'Software Development' started by Regicide, Nov 18, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. Regicide

    Regicide Thread Starter

    Joined:
    Aug 8, 2003
    Messages:
    307
    I'm making a program to copy files to my network (I'm making it in a console). I can send the file and everything no problem, but my problem is that I want to have it continually update how many bytes have been sent while keeping the current text on the screen. E.G.

    I wouldn't like to have it erase the screen everytime a new byte is sent (SYSTEM("cls")). Anyone have any ideas?
     
  2. AlbertB

    AlbertB

    Joined:
    Nov 24, 2002
    Messages:
    2,438
    I like your idea of keeping the display simple.

    One way to solve it very simply is to start by working out what N% of the total bytes to transfer is, starting with N=1. Then when transfer is proceeding constantly monitor the total number of bytes passed, and compare the two. When you pass the N% amount, increment N and recalculate to step to the next %, and update the screen. This way you only address the screen at intervals.

    To take into account speed considerations, the incremental %ge could step in increments of 2, 5, 10, 20 or anything you like depending on the total number of bytes to transfer.
     
  3. coderitr

    coderitr

    Joined:
    Oct 12, 2003
    Messages:
    3,015
    See the SetConsoleCursorPosition( ) function in the MSDN library.
     
  4. Regicide

    Regicide Thread Starter

    Joined:
    Aug 8, 2003
    Messages:
    307
    Thanks to both of you! SetConsoleCursorPosition() works great!
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Overwritting Text (with
  1. martinlest
    Replies:
    1
    Views:
    157
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/180544

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice