C99 標準未定義 fflush,可改用以下方法:

main.c 使用…
用於 cpp 是無效的,僅限 c 檔案
while(((_ch = getchar()) != '\n') & (_ch != EOF));

所以 system("PAUSE"); 可改用…
while(((_ch = getchar()) != '\n') & (_ch != EOF));
_ch = getchar();

或者是…
void MyPause(char* _ch)
{
    //
    // fflush(stdin)
    while(((*_ch = getchar()) != '\n') & (*_ch != EOF));
    //
    // get a character from stdin
    *_ch = getchar();
}

main.cpp 使用…
cin.sync() 是未定義且僅限 Windows 使用
#include<limits>
using std::cin;
using std::cout;
using std::endl;
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

所以 system("PAUSE"); 可改用…
#include<limits>
using std::cin;
using std::cout;
using std::endl;
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "press any key to continue...";
cin.get();

 

arrow
arrow
    全站熱搜

    耗呆肥羊 發表在 痞客邦 留言(0) 人氣()