我有以下代码在用 C++ 编写的命令行应用程序中运行
std::string filename = m_arguments[1];
unsigned long long size = stoll(m_arguments[2]);
char character = m_arguments[3].c_str()[1];
FILE *pFile;
if( (pFile = fopen(filename.c_str(), "wb")) != NULL)
{
for(int i = 0; i<size; i++)
{
fputc(character, pFile);
unsigned long long per = 100*i/size;
if(per % 10 == 0) { cout<<"\r"<<per<<"%"<<flush; }
}
fclose(pFile);
}
cout<<endl;
百分比在命令行上闪烁。我试图减少闪烁,if(per%10 == 0)
但没有任何变化。我能做些什么来阻止这种闪烁?