Results 1 to 7 of 7

Thread: I have a couple of questions...

  1. #1

    Thread Starter
    Addicted Member Fat_N_Furry's Avatar
    Join Date
    Oct 2002
    Posts
    171

    I have a couple of questions...

    In command prompt programming...
    [list=1][*]How do you convert a user's input to asterisks as he/she is typing? [*]How do you detect if the user is typing characters that are non-numeric?[/list=1]


    Thanks!
    Rick
    Eat long and prosper!
    If someone helps you, find someone you can help.
    If you still have time, click on the darn banner up there and help the forum!

  2. #2
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    I've never done this so I can't be more help but for #1, youll have to hook the keyboard to get the data before the screen does... I do know you can do this though.
    I figure #2 is answered by this, just compare the hooked data to your known asc codes

    Google Search!

    NOMAD

  3. #3
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    getch() will allow for you to input characters without echoing them to the screen. Then cout *'s to the screen for each character entered.

    Now, if you want backspace, that is a bit difficult. If you are using Borland C++, clrscr() contained in conio.h (yes, i know that this header is depreciated but I do not have access to my complier right now to check.) will allow you to clear the screen and then redisplay your screen.

    Now for #2:
    if ((character <= 'a' && character >= 'z') && (character <= 'A' && character >= 'Z'))
    // It is an alphabetic character. (If you are supporting different languages, check for valid characters the same way as I did above.)

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    conio.h isn't deprecated but it isn't standardized. clrscr is only available in Borland though.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142
    x = getch(); //will get the character the user gave

    if( (x >= 48) && (x <= 57) // this will check the input is numeric

    if( (x < 48) && (x > 57) ) //do the opposite, non-numeric

    <stdlib.h> ( im pretty sure thats it, if not its got some letters in front of it )
    allows you to call

    system("clr");

    to clear the screen if you can't use clrscr();
    ؊Ϯϊ

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    system("cls");

    The DOS clear screen app is called cls, not clr. In UNIX it would be "clear".
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Addicted Member Fat_N_Furry's Avatar
    Join Date
    Oct 2002
    Posts
    171
    Cool! I'll try it out and let you know what happens.


    Thanks, guys!
    Rick
    Eat long and prosper!
    If someone helps you, find someone you can help.
    If you still have time, click on the darn banner up there and help the forum!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width