13,826
社区成员
发帖
与我相关
我的任务
分享
#include <algorithm>
#include <functional>
#include <ctype.h>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
using namespace std;
char *str="abc\t\r\nefg\bh\rig";
char *pLast = remove_if(str,str+strlen(str),not1(ptr_fun(isprint)));
*pLast = 0;
ShowMessage(str);
}
isprint, iswprint, _ismbcprint
Header File
ctype.h, wctype.h, mbstring.h
Category
Classification Routines
Prototype
int isprint(int c);
int iswprint(wint_t c);
int _ismbcprint(unsigned int c);
Description
Tests for printing character.
isprint is a macro that classifies ASCII-coded integer values by table lookup. The macro is affected by the current locale’s LC_CTYPE category. For the default C locale, c is a printing character including the blank space (‘ ‘).
You can make this macro available as a function by undefining (#undef) it.
Return Value
isprint returns nonzero if c is a printing character.
#include <stdio.h>
#include <ctype.h>
int main(void)
{
char c = 'C';
if (isprint(c))
printf("%c is a printable character\n",c);
else
printf("%c is not a printable character\n",c);
return 0;
}
//成员变量
set<char> m_setChar;
//构造函数
__fastcall TFormMain::TFormMain(TComponent* Owner)
: TForm(Owner)
{
for(int i = 32;i<127;i++)
{
m_setChar.insert(i);
}
}
//我的函数体对我接受到的字符串开始处理
for(int m = 1;m<=strReceiveText.Length();m++)
{
if(m_setChar.find(strReceiveText[m])== m_setChar.end())
{
strReceiveText.Delete(m,1);
m--;
}
}