Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > A couple of questions on console program

Reply
Thread Tools

A couple of questions on console program

 
 
Sam Hu
Guest
Posts: n/a
 
      05-21-2009
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
 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      05-21-2009
"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.


 
Reply With Quote
 
 
 
 
Linlin Yan
Guest
Posts: n/a
 
      05-21-2009
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 <SamHu.Sa...@gmail.com> 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

 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      05-21-2009
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;
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      05-21-2009
On May 21, 3:04 am, Sam Hu <SamHu.Sa...@gmail.com> 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
 
Reply With Quote
 
Sam Hu
Guest
Posts: n/a
 
      05-22-2009
Thank you so much for all your help!

Regards,
Sam
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing the console window from closing when writing a console program in C++ Miktor C++ 7 08-09-2005 09:22 PM
Newbie questions - Couple of VC++ questions regarding dlls and VB6 Ali Syed C Programming 3 10-13-2004 10:15 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Serge Terekhoff Python 0 06-30-2003 12:36 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Egor Bolonev Python 0 06-30-2003 10:43 AM
Re: console mp3->wav decoder for $indows or GUI one which supports console Ben Finney Python 2 06-30-2003 05:43 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57