#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main() {
// string a;
// cout<<"size = "<<a.size()<<endl;
// cout<<"length = "<<a.length()<<endl;
// a.reserve(100);
// cout<<"size = "<<a.size()<<endl;
// cout<<"length = "<<a.length()<<endl;
// a.resize(123);
// cout<<"size = "<<a.size()<<endl;
// cout<<"length = "<<a.length()<<endl;
// char a[]="0123456789";
// printf("sizeof(a) = %d\n",sizeof(a));
// char *b="0123456789";
// printf("sizeof(b) = %d\n",sizeof(b));
// cout<<sizeof(char)<<ends<<sizeof(char*)<<endl;
// string a="12345679";
a.resize(5);
scanf("%s",a.c_str());
cout<<a;
// printf("%s",a.c_str());
// char a='0';
// printf("%d %o %x\n",a,a,a);
// char b='\0';
// printf("%d %o %x\n",b,b,b);
// char a[5]="12345";//error
// char a[5];
// cout<<sizeof(a)<<endl;
// char b[]="13245";
cout<<sizeof(char*)<<endl;
// cout<<sizeof(b);
return 0;
}
C++ #014 char[] length size char* string 02
于 2021-03-15 21:57:18 首次发布