#C++初学记录#日常学习函数
静态变量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