Blocking Alpha characters

This is a discussion on Blocking Alpha characters within the C Programming forums, part of the General Programming Boards category; To start-- like many others-- I'm teaching myself C programming. It's been okay, but I have hit a speed bump-- ...

  1. #1
    Registered User
    Join Date
    Feb 2005

    Question Blocking Alpha characters

    To start-- like many others-- I'm teaching myself C programming. It's been okay, but I have hit a speed bump--

    I'm doing a currency conversion program and I have limited the user to just being able to select the number 1 to convert Pounds to US Dollars. I have my screen clear and reset if the user chooses a different number. However, if the user hits an alpha character, such as A, then the screen just goes black and sits there. How can I get the screen to reset or tell the user to try again if he/she hits an alpha character?

    Thanks in advance for your help!

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:

    You might also want to read the posting guidelines:

    I think you might get some better responses to your question if you posted your code so people could have a look at it.

    If you have any questions about any of the guidelines you may ask or you can contact one of our forum leaders:

    Good luck teaching yourself!

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Registered User
    Join Date
    Feb 2005

    Smile Code for Alpha Characters

    At the request, here is my code--- God, I hope I posted it correctly-- hate to make anybody mad when I'm the one looking for help!!

    #include <stdio.h> 
         #include <conio.h> 
         #define GBP 1.8904; /* British Pound conversion rate    
         int main(void)
    	float usd;
    	float newrate;
    	int selection;
    printf("This program will convert British Pounds to US Dollars\n");
    printf("\n\nPlease Select The Number 1 And Press ENTER To Convert Pounds To Dollars:\n");
    printf("[1] British Pound\n");
    scanf ("%d", &selection);
    printf("You entered %d\n", selection);
    	while (selection != 1);
    printf("\n\nPlease enter the amount of money you want to convert to US Dollars\n\n\n");
    scanf("%f", &usd);
    newrate = usd * GBP; 
    printf("\nThat amount in US Dollars is: $%.2f \n\n\n", newrate);
    printf("\n\nThank you!  \nHave a great day! \nPress any key to exit\n");
    	return 0;

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    FAQ > How do I... (Level 1) > How do I get a number from the user (C)

    [edit]Search the board for "dollars".
    Last edited by Dave_Sinkula; 02-26-2005 at 10:29 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. populating a string only alpha characters
    By MSF1981 in forum C Programming
    Replies: 10
    Last Post: 02-06-2009, 10:58 AM
  3. Replies: 10
    Last Post: 07-10-2008, 04:45 PM
  4. Replies: 23
    Last Post: 07-09-2007, 05:49 AM
  5. Incrementing alpha characters. Base36
    By chops11 in forum C++ Programming
    Replies: 5
    Last Post: 07-18-2006, 03:56 PM

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