静态变量static,只进行一次初始化。

#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	for(int i=0;i<3;i++)
	{
	int static n=5;
	cout<<n<<endl;
	n++;
	}

	return 0;
}

put :5 6 7。
string库:
strtok库函数实现,能实现字符串的分割.

#include<cstring>
#include<iostream>
int main()
{

char str[ ]="This , a sample string OK."
char * p =strtok(str," ,.-");
while(p!=NULL)
{
	cout<<p<<endl;
	p=strtok(NULL," ,.-");
	
 } 
 return 0;
}

put :
This
a
sample
string
OK

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2021-06-25
  • 2021-12-22
  • 2021-06-21
  • 2021-12-15
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2022-01-17
  • 2021-11-24
  • 2022-02-05
  • 2021-06-28
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案