Thread: Newbie need some help

  1. #16
    Registered User taazz's Avatar
    Join Date
    May 2016
    Posts
    50
    Quote Originally Posted by laserlight View Post
    Which is fine, except that you should remember that you answered spdragon's post in the general-purpose C programming forum. You did not venture your own topic with constraints specific to yourself, or perhaps replied in the Windows programming forum where certain assumptions can be more readily made, even if they remain undefined behaviour.
    lets assume for a moment that you are right, at least my post was about the problem can you say the same thing?
    Quote Originally Posted by laserlight View Post
    This has already been answered by Salem's post #4.
    The concern about fflush(stdin) ceased to be interesting after post #4; you should have been out after post #4 if you only wanted to argue about fflush(stdin). Whether this thread remains interesting in general is up to spdragon to decide.
    No the link provided had all the information on why it might fail and some half solution that could lead to double input from the end user. I did provided a working solution and the systems I tested on. If salem, you or any one else wants to provide a solution for the systems they are interested in I would be very interested on that answer, but most of them have opted to attack my intelligence or lack there of, ignoring the problem all together and never adding anything of value to the discussion.

    Any way I'm here because I found what it looks an acceptable solution to the dilemma, instead of using the fflush just use rewind eg
    Code:
            printf("Error, Do you want to restart the program (y/n)");
            rewind(stdin);
            scanf("%c",&selection2);
    I'm always interested in any criticism on the code for everything else fill free to pm me I'm open to discuss anything you like as long as I find it interesting but do try to keep the thread on subject.

    PS
    Salem I'm not targeting you, from all the people in here, you are the only one that added something of value at least of value to me. for every one else please do not confuse courtesy with interest or boredom with but-hurt, you are entitled to your opinions and you are welcome to express them but do try to add something of value as well.

  2. #17
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by taazz View Post
    lets assume for a moment that you are right, at least my post was about the problem can you say the same thing?
    The problem is that, when someone gives bad advice, it's necessary to counter it with facts. This is exactly what happened. Just because it "works for me," it doesn't mean it isn't wrong, and if it is objectively wrong, then you shouldn't do it, regardless of the results on your chosen platform.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #18
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Any way I'm here because I found what it looks an acceptable solution to the dilemma, instead of using the fflush just use rewind eg
    Actually, for this problem, why not just force scanf() to skip leading whitespace?
    Code:
    scanf(" %c",&selection2); /* Note the leading space in the format specifier. */
    It appears that the problem is being caused by the new line character left in the input buffer by the previous scanf().

    Jim

  4. #19
    Registered User taazz's Avatar
    Join Date
    May 2016
    Posts
    50
    Quote Originally Posted by jimblumberg View Post
    Actually, for this problem, why not just force scanf() to skip leading whitespace?
    Code:
    scanf(" %c",&selection2); /* Note the leading space in the format specifier. */
    It appears that the problem is being caused by the new line character left in the input buffer by the previous scanf().

    Jim
    Nice! I did not know it could be done that way, thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hello, I am a newbie and so I have a newbie question;)
    By piratemonkey247 in forum C Programming
    Replies: 4
    Last Post: 12-20-2012, 10:59 AM
  2. newbie
    By honeythigh in forum C++ Programming
    Replies: 10
    Last Post: 03-05-2011, 08:05 AM
  3. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  4. newbie q!
    By xzentorian in forum C++ Programming
    Replies: 6
    Last Post: 12-19-2004, 04:38 PM
  5. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM

Tags for this Thread