From ba3b18d726aa66ccca8a832feb987f527981e467 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 11 May 2018 15:52:50 +0800 Subject: [PATCH] Fix compile error under VS2017 --- ConsoleUI/ColorUI.cpp | 13 +++++++++---- example.cpp | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ConsoleUI/ColorUI.cpp b/ConsoleUI/ColorUI.cpp index 1a99efd..642f477 100644 --- a/ConsoleUI/ColorUI.cpp +++ b/ConsoleUI/ColorUI.cpp @@ -1,7 +1,7 @@ #include "ColorUI.h" +#include #include -#include -#include +#include // getch namespace _cns { @@ -175,12 +175,12 @@ int GetAction(int& cid,int MinVal,int MaxVal,int EscapeVal) { case KEY::UP: { - cid=std::max(std::min(cid-1,MaxVal),MinVal); + cid=max(min(cid-1,MaxVal),MinVal); return 0; } case KEY::DOWN: { - cid=std::max(std::min(cid+1,MaxVal),MinVal); + cid=max(min(cid+1,MaxVal),MinVal); return 0; } case KEY::ESC: @@ -205,6 +205,11 @@ int GetAction(int& cid,int MinVal,int MaxVal,int EscapeVal) } } +static void ClearInputBuffer() +{ + scanf("%*[^\n]%*c"); +} + }/// End of namespace _cns ColorSelection::ColorSelection() diff --git a/example.cpp b/example.cpp index a737665..9c7290d 100644 --- a/example.cpp +++ b/example.cpp @@ -1,4 +1,5 @@ #include "ConsoleUI/ColorUI.h" +#include using namespace std; class ReturnButton : public ColorSelection @@ -88,11 +89,12 @@ public: while(scanf("%d%*c",&input)!=1) { printf("Invalid Input.\n"); + scanf("%*[^\n]%*c"); } printf("Well Done! You inputed: %d\n",input); printf("You may have understand it. Now Press ENTER To Continue.\n"); char buff[1024]; - gets(buff); + fgets(buff, 1024, stdin); } };