zoukankan      html  css  js  c++  java
  • sizeof 用法部分总结

    #include<iostream>
    #include<string.h>
    using namespace std;
    struct s1
    {
    	char a[8];
    };
    
    struct s2
    {
    	double d;
    };
    
    struct s3
    {
    	s1 s;
    	char a;
    };
    
    struct s4
    {
    	s2 s;
    	char a;
    };
    struct s5
    {
    	int i : 8;
    	int j : 4;
    	int a : 3;
    	double b;
    };
    
    int main(){
    	
    	int  *p1;
    	cout << sizeof(p1) << endl;
    	cout << sizeof(*p1) << endl;
    	cout << "~~~~~~~~~~~~~~~~~~~~~~" << endl;
    	char  *p2;
    	cout << sizeof(p2) << endl;
    	cout << sizeof(*p2) << endl;
    	cout << "~~~~~~~~~~~~~~~~~~~~~~" << endl;
    	int a[10];
    	char b[] = "hello";
    	string s = "hello";
    	cout << sizeof(a) << endl;   //
    	cout << sizeof(b) << endl;   //计算‘’
    	cout << strlen(b) << endl;   //不计算''
    	cout << sizeof(s) << endl;
    	cout << s.size() << endl;
    	cout << s.capacity()<<endl;
    	cout << "~~~~~~~~~~~~~~~~~~~~~~" << endl;
    	cout << sizeof(s1) << endl; // 8
    	cout << sizeof(s2) << endl; // 8
    	cout << sizeof(s3) << endl; // 9
    	cout << sizeof(s4) << endl; // 16;
    	cout << sizeof(s5) << endl; // 16;
    	system("pause");
    	return true;
    }
    

      

  • 相关阅读:
    JPA实体
    JPA简介
    Spring_boot_pom.xml和启动方式
    Hibernate中的Query
    Spring_Hibernate整合准备
    redis 常见问题
    python 操作redis
    大数据平台的搭建思路
    LEFT SEMI JOIN
    HDFS小文件问题及解决方案
  • 原文地址:https://www.cnblogs.com/wujufengyun/p/6755530.html
Copyright © 2011-2022 走看看