终极实战指南:如何用Win11Debloat专业优化Windows系统,告别臃肿与隐私泄露
2026/4/28 15:43:23
#include<iostream>#include<cstring>using namespace std;intmain(void){structstu{intage;charname[20];voidwho(void){cout<<"我是:"<<name<<" 我今年:"<<age<<endl;}};stu s1;s1.age=21;strcpy(s1.name,"张飞");s1.who();return0;}unionXX{……};XX x;//定义联合体变量直接省略unionunion{//没有名字……};#include<iostream>usingnamespacestd;intmain(void){union{//匿名联合intnum;charc[4];};num=0x12345678;cout<<hex<<(int)c[0]<<" "<<(int)c[1]<<endl;return0;}#include<iostream>usingnamespacestd;intmain(void){enumCOLOR{RED,GREEN,BLUE};COLOR c=GREEN;//c = 2; //errorcout<<c<<endl;return0;}#include<iostream>usingnamespacestd;intmain(void){boolb=true;cout<<b<<endl;cout<<boolalpha<<b<<endl;b=3+2;cout<<boolalpha<<b<<endl;return0;}string s;//定义空字符串strings("hello");string s="hello";string s=string("hello");string s1=“hello”;string s2=s1;string s1=“hello”,s2=“ world”;string s3=s1+s2;//s3:hello worlds1+=s2;//s1:hello worldstring s1=“hello”,s2=“ world”;if(s1==s2){cout<<“false”<<endl;}if(s1!=s2){cout<<“true”<<endl;}string s=“hello”;s[0]=“H”;//Hellosize_tsize();size_tlength();constchar*c_str();voidswap(string s1,string s2);#include<iostream>#include<cstdio>usingnamespacestd;intmain(){/*定义*/string s1;//定义空字符串strings2("aaa");string s3=string("bbb");string s4="cccc";/*字符串的拷贝*/string s5=s2;// char *p5 = p2;cout<<"s5 = "<<s5<<endl;/*拼接*/s5+=s3;cout<<"s5 = "<<s5<<endl;/*字符串比较*/if(s2==s3){//strcmp(.....)cout<<"true"<<endl;}else{cout<<"false"<<endl;}/*取字符串长度*/cout<<"s5 length = "<<s5.length()<<endl;/*转换为C风格字符串*/constchar*p=s5.c_str();printf("%s\n",p);/*交换*/swap(s2,s3);cout<<"s2= "<<s2<<" s3= "<<s3<<endl;return0;}