A couple of questions on console program

Discussion in 'C++' started by Sam Hu, May 21, 2009.

  1. Sam Hu

    Sam Hu Guest

    Hello,

    I am always wondering,in many console apps I have ever seen,how one
    can make this in C++:

    1.password mask "*",when one is asked to enter the password ,say
    "1234",it displays "****";
    2.progress indidating.say when one want to show the completeness by
    percentage of the current task going,other than showing below
    information:

    copying files 5% completed.
    copying files 6% completed.
    .....
    how one just let show in a single line:

    copying files xx% completed

    only the percentage is increasing or decreasing in certain interval.

    3.how to ask the user to input in a fixed position,say below prompt
    from an app:

    your name is ____ and you are __ years old.
    The cursor is exact at the postion after "is ".
    when the user input a string and hit some key,the cursor is re-
    positioned at the point exact after "are ".Another word,something like
    the BIOS setup ultility.

    4.someone told me that one can play a music/song on the keyboard,how?
    5.how to create a menu just like the BIOS setup ultility?
    6.how to display an icon/logo,just like the one Norton Ghost does.

    It would be grateful if someone can help.

    Regards,
    Sam
    Sam Hu, May 21, 2009
    #1
    1. Advertising

  2. Sam Hu

    osmium Guest

    "Sam Hu" wrote:

    > I am always wondering,in many console apps I have ever seen,how one
    > can make this in C++:
    >
    > 1.password mask "*",when one is asked to enter the password ,say
    > "1234",it displays "****";
    > 2.progress indidating.say when one want to show the completeness by
    > percentage of the current task going,other than showing below
    > information:
    >
    > copying files 5% completed.
    > copying files 6% completed.
    > ....
    > how one just let show in a single line:
    >
    > copying files xx% completed
    >
    > only the percentage is increasing or decreasing in certain interval.
    >
    > 3.how to ask the user to input in a fixed position,say below prompt
    > from an app:
    >
    > your name is ____ and you are __ years old.
    > The cursor is exact at the postion after "is ".
    > when the user input a string and hit some key,the cursor is re-
    > positioned at the point exact after "are ".


    You can't do these with the basic offerings. Look for <conio.h> it will
    answer many, perhaps all of those questions. You can dig through the
    newsgroup archives for a start. Your (later) mention of Norton Ghost makes
    me think you are using something related to Windows. The include file is
    different for Unix.
    osmium, May 21, 2009
    #2
    1. Advertising

  3. Sam Hu

    Linlin Yan Guest

    I am afraid that some of your questions are off-topic in comp.lang.c+
    +. They depend on different platform. You can try to find some
    libraries such as
    curses which enable you control the screen cursor and output styles.

    On May 21, 9:04 am, Sam Hu <> wrote:
    > Hello,
    >
    > I am always wondering,in many console apps I have ever seen,how one
    > can make this in C++:
    >
    > 1.password mask "*",when one is asked to enter the password ,say
    > "1234",it displays "****";
    > 2.progress indidating.say when one want to show the completeness by
    > percentage of the current task going,other than showing  below
    > information:
    >
    > copying files 5% completed.
    > copying files 6% completed.
    > ....
    > how one just let show in a single line:
    >
    > copying files xx% completed

    this can be easily used like:
    printf("copying files %d%% completed.\r", progress);
    fflush(stdout);

    >
    > only the percentage is increasing or decreasing in certain interval.
    >
    > 3.how to ask the user to input in a fixed position,say below prompt
    > from an app:
    >
    > your name is ____ and you are  __ years old.
    > The cursor is exact at the postion after "is ".
    > when the user input a string and hit some key,the cursor is re-
    > positioned at the point exact after "are ".Another word,something like
    > the BIOS setup ultility.
    >
    > 4.someone told me that one can play a music/song on the keyboard,how?
    > 5.how to create a menu just like the BIOS setup ultility?
    > 6.how to display an icon/logo,just like the one Norton Ghost does.
    >
    > It would be grateful if someone can help.
    >
    > Regards,
    > Sam
    Linlin Yan, May 21, 2009
    #3
  4. Linlin Yan wrote:
    > this can be easily used like:
    > printf("copying files %d%% completed.\r", progress);
    > fflush(stdout);


    Since this is a C++ group, let's also give the more C++'ish solution:

    std::cout << "Copying files " << progress << "% completed.\r"
    << std::flush;
    Juha Nieminen, May 21, 2009
    #4
  5. Sam Hu

    James Kanze Guest

    On May 21, 3:04 am, Sam Hu <> wrote:

    > I am always wondering,in many console apps I have ever
    > seen,how one can make this in C++:


    > 1.password mask "*",when one is asked to enter the password ,say
    > "1234",it displays "****";
    > 2.progress indidating.say when one want to show the completeness by
    > percentage of the current task going,other than showing below
    > information:


    > copying files 5% completed.
    > copying files 6% completed.
    > ....
    > how one just let show in a single line:


    > copying files xx% completed


    > only the percentage is increasing or decreasing in certain interval.


    > 3.how to ask the user to input in a fixed position,say below prompt
    > from an app:


    > your name is ____ and you are __ years old.
    > The cursor is exact at the postion after "is ".
    > when the user input a string and hit some key,the cursor is re-
    > positioned at the point exact after "are ".Another word,something like
    > the BIOS setup ultility.


    None of the above is supported by standard C++. Typically,
    you'll either need something platform specific, or a portable
    library---ncurses is almost a standard for this sort of thing.

    > 4.someone told me that one can play a music/song on the keyboard,how?


    Who knows? The machines I usually work on don't have any such
    possibility (the only sound they support is the beep from the
    keyboard), and it's not supported by C++.

    > 5.how to create a menu just like the BIOS setup ultility?


    ncurses? (I don't really know what the BIOS setup utility menu
    looks like.)

    > 6.how to display an icon/logo,just like the one Norton Ghost does.


    You need to use the GUI. Again, implementation dependent, or an
    external library (wxWidgets, etc.).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, May 21, 2009
    #5
  6. Sam Hu

    Sam Hu Guest

    Thank you so much for all your help!

    Regards,
    Sam
    Sam Hu, May 22, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne  Wengert

    A Couple of Questions

    Wayne Wengert, Jan 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    314
    =?Utf-8?B?aSBkb250IGtub3cgbXVjaCBhYm91dCB2cy4uLmI=
    Jan 22, 2004
  2. Martin

    A Couple Of Questions

    Martin, Mar 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    336
    Mark Jerde
    Mar 6, 2004
  3. =?Utf-8?B?UnVkeQ==?=

    Couple of questions

    =?Utf-8?B?UnVkeQ==?=, Dec 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    314
    =?Utf-8?B?UnVkeQ==?=
    Dec 27, 2004
  4. Ali Syed
    Replies:
    3
    Views:
    545
    Mark McIntyre
    Oct 13, 2004
  5. Miktor
    Replies:
    7
    Views:
    12,002
    Joe Bacigalupa
    Aug 9, 2005
Loading...

Share This Page