Thread: Windows.h interfering with max(); (for clearing input buffer)

  1. #1
    Registered User
    Join Date
    Sep 2018
    Posts
    194

    Windows.h interfering with max(); (for clearing input buffer)

    cin.ignore(std::numeric_limits<std::streamsize>::m ax(), '\n');

    So the above code is used for clearing the input buffer and it works great.

    But when I include <windows.h> then I get all sorts of errors relating to "max()", you can see for yourself.

    How do I use the line above mentioned without having windows.h interfere with it while still having windows.h included to the program?

  2. #2
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    814
    Doing a websearch, the top result tackled the issue.

  3. #3
    Registered User
    Join Date
    Sep 2018
    Posts
    194
    Damn adrian what did you search? You need to train me in your Googling skills!

    By the way since we're here is
    cin.ignore(cin.rdbuf()->in_avail());

    a better way to clear the cin buffer?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stuck on clearing the input buffer
    By ImageJPEG in forum C Programming
    Replies: 10
    Last Post: 12-20-2017, 02:01 PM
  2. Clearing c++ input buffer
    By mramazing in forum C++ Programming
    Replies: 4
    Last Post: 11-08-2007, 11:05 AM
  3. Clearing the input buffer
    By caduardo21 in forum C Programming
    Replies: 1
    Last Post: 05-14-2005, 08:40 PM
  4. Clearing the Input buffer
    By Brain Cell in forum C Programming
    Replies: 5
    Last Post: 03-21-2004, 12:08 PM
  5. text input buffer clearing
    By red_Marvin in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2003, 03:17 PM

Tags for this Thread