Thread: Double Hops but why ???

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The easy way to fix the "extra newline" problem is to simply add the option to skip it to your scanf call:

    scanf( "%c%*c", &myVar );

    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    Where do I put this line of code ? At the top or....what ?

    Also do I have to define fgets(buffer, max_input_size, stdin) or no ?

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can handle this one of two ways:

    1) assume your user will enter the correct info, and in which case, just replace this:
    Code:
    printf ("\nAre you finished using the Newton Raphson's Root finder ?"); 
    scanf("%c", &f);
    With this:

    Code:
    printf ("\nAre you finished using the Newton Raphson's Root finder ?"); 
    scanf("%c%*c", &f);
    2) You can do it the "safer" way, which will read into a buffer then parse the buffer. In this case, use fscanf instead of your regular scanf call.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    Feb 2002
    Posts
    52

    Thumbs up

    Thanks for all the help guys I think I got that double hop thing fixxed I put a do while loop in there works like a champ. Okay guys thanks again !!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copying 2-d arrays
    By Holtzy in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2008, 03:44 PM
  2. C++ to C Conversion
    By dicon in forum C Programming
    Replies: 7
    Last Post: 06-11-2007, 08:38 PM
  3. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  4. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  5. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 06:54 PM