当前位置:网站首页>[isprint function determines whether characters can be output]

[isprint function determines whether characters can be output]

2022-07-23 21:33:00 Li is struggling

【isprint() Function to determine whether a character is printable .'  ' Space 】

#include <iostream>

#include <string.h>

using namespace std;

int main()

{

 string s = "12d1 2 ddsd";

 int d = 0;

 for (int i = 0; i<s.length(); i++)

 {

  if (s[i] != ' ' && isprint(s[i])) // Judge not to be a space And can output ;

  {

   s[d++] = s[i];

  }

 }

 cout << " The changed string is :" << endl;

 for (int i = 0; i < d; i++)

 {

  cout << s[i];

 }

}

4ac9b2c972d64db78c8cd6f1725a4763.png

 

 

原网站

版权声明
本文为[Li is struggling]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207232020176665.html