Help! with character validity check

This is a discussion on Help! with character validity check within the C Programming forums, part of the General Programming Boards category; Thanks this has helped a lot. Maybe I can get it now. I'll give this theory a try and see ...

  1. #16
    Registered User
    Join Date
    Jul 2007
    Posts
    10
    Thanks this has helped a lot. Maybe I can get it now. I'll give this theory a try and see what I get. I'm sure i'll be back with more questions.

    I only have one more week of this 5 week class, and have realized I have just skimmed the surface of "C" and do not know it well enough too save my bacon.

    Thanks everyone for help.
    Tamara

  2. #17
    Registered User
    Join Date
    Jul 2007
    Posts
    10
    Well I've tried every suggesting and still cannot get the character check to work. My last attempt had an endless loop of two re-enters across the screen. The program works great until I try to add this character check. Then nothing works right. Attached is my latest version without the character check.

    I have learned a lot even though my program still does not work. I am very thankful for all of the help. Thanks everyone.

    Tamara
    Attached Files Attached Files

  3. #18
    Registered User
    Join Date
    Jul 2007
    Posts
    10
    After trial and error and all the responses I finally got the program to run it just needed this
    Code:
    iResponse = scanf("%f", &fSubtotal );
    
    while (fSubtotal < fCheck || iResponse != 1){
    	fflush(stdin);
    	printf("\n\tPlease Re-enter your Subtotal: $");
    	iResponse = scanf("%f", &fSubtotal );
    	}//end while loop
    The reason it kept loopping is I needed to flush the variable. How wierd but it works.
    Thanks again

    Attached is the final program. That works great.
    Attached Files Attached Files

  4. #19
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Well its good to hear you got it running. fflush(stdin) is not meant to be a good way to flush the input buffer tho. Heres an explanation of why. And Heres an example of a better method.

  5. #20
    Registered User
    Join Date
    Jul 2007
    Posts
    10
    Thanks Mike

    Since yesterday I have learned more about "C" in one 24-hour period than the whole 4 weeks of class

    Tamara

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Not working in linux...
    By mramazing in forum C++ Programming
    Replies: 6
    Last Post: 01-08-2009, 01:18 AM
  2. allegro issues
    By mramazing in forum C++ Programming
    Replies: 1
    Last Post: 01-07-2009, 10:56 PM
  3. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  4. syntax error when defining vectors
    By starkhorn in forum C++ Programming
    Replies: 5
    Last Post: 09-22-2004, 12:46 PM
  5. Pointer validity check
    By Carlos in forum Windows Programming
    Replies: 6
    Last Post: 12-11-2003, 02:40 AM

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