#include <iostream>
#include <cstring>
using namespace std;
struct dd
{
int a;double b;
};
struct aa
{
dd t,q;
};
struct qq
{
aa o;
};
int main()
{
qq z[10];
z[0].o.t.a=10;//结构体的嵌套格式
std::ios::sync_with_stdio(false);//取消同步
char
greet[100]="\"""""""\"Hello \n\n\n\n\n\n\n\n\nworld!"
"gjaoijodsmfsdmmmmmmmmmm"; //用""来换行接上一行
//greet[80]='8';
char s[100];
cin.ignore(80,'\n');//从输入流中删除多余的字符 包括'\n'
cin.getline(s,10,'3');//'3' can also be alternated by '@' 'a' **** And the default is' \n '
cout << greet<<endl<<strlen(greet)<<endl;//strlen是读到第一个'\0' 为止 后面什么样不管
cout <<s<<endl;
char name1[7]="fucker";//name1[6]='1'; ←--------------┓
char name2[10]="8"; // ┃
strcpy(name2,name1);//name1 必须以'\n' 结束 如果这样---┚
cout << name2<<endl;//name2="fucker"
if (strcmp(name1,name2)==0) cout <<"Yes"<<endl;//如果两个字符串相等返回0 1>2返回值为正 1<2 为负
//常用的还有 strncat(str1,str2,n)
// strncpy(str1,str2,n)
//char s[]="123456";
//int t; t=atoi(s); 转换字符串为数值 atof转成小数 需包含 #include<cstdlib>
return 0;
}
c风格字符串
最新推荐文章于 2015-08-19 10:01:35 发布