---
title: "C++  基本数据类型字节数"
author: "mywebcode"
date: "2014-04-16T14:57:00Z"
tags: []
slug: "c"
draft: false
lastmod: "2014-04-30T09:13:58Z"
id: 2058249
url: "https://mywebcode.iteye.com/blog/2058249"
---

```
#include <iostream>
using namespace std;

int main() {
	cout << "Size of bool = " << sizeof(bool) << endl;
	cout << "Size of char = " << sizeof(char) << endl;
	cout << "Size of short = " << sizeof(short) << endl;
	cout << "Size of unsigned short = " << sizeof(unsigned short) << endl;
	cout << "Size of int = " << sizeof(int) << endl;
	cout << "Size of unsigned int = " << sizeof(unsigned int) << endl;
	cout << "Size of long = " << sizeof(long) << endl;
	cout << "Size of unsigned long = " << sizeof(unsigned long) << endl;
	cout << "Size of float = " << sizeof(float) << endl;
	cout << "Size of double = " << sizeof(double) << endl;
	cout << "Size of long double = " << sizeof(long double) << endl;
	cout << "Size of long long = " << sizeof(long long) << endl;

	return 0;
}
```