isprint()导致exe崩溃 [英] isprint() is leads to exe crashing
本文介绍了isprint()导致exe崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用isprint()来查看能否打印的字符。
我正在传递像'μTorrent'这样的输入它的车载...(μ )
但其他输入工作正常..
I am using isprint()to check the char able to print or not.
I am passing the input like 'µTorrent' Its carshing .. (µ)
But other inputs its working fine..
char *cpTemp = new char[str_Input.length()+1]; //str_Input i am having the input string
sprintf(cpTemp, "%s", str_Input.c_str());
int nLength = str_Input.length();
while(nLength)
{
char cTemp = *cpTemp;
if(isprint(cTemp))
{
}
}
推荐答案
这是符号扩展字符大于0x7F的结果。请尝试使用以下代码:
This is the result of sign extending characters greater than 0x7F. Try the following code instead:
for (string::iterator it = str_Input.begin(); it < str_Input.end(); it++)
{
unsigned char cTemp = *it;
if(isprint(cTemp))
{
cout << cTemp << " is printable" << endl;
}
}
这篇关于isprint()导致exe崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文