本帖最後由 陳品叡 於 2024-8-9 16:04 編輯
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int intvar = 100;
- float floatvar = 0.369;
- double doublevar = 12.6598;
- long double longdvar = 12.369;
- string strvar1 = "我是字串";
- char strvar2[] = "我是字元陣列";
- cout << "intvar \t" << &intvar << "\t\t" << sizeof(intvar) << endl;
- cout << "floatvar \t" << &floatvar << "\t\t" << sizeof(floatvar) << endl;
- cout << "doublevar\t" << &doublevar << "\t\t" << sizeof(doublevar) << endl;
- cout << "longdvar \t" << &longdvar << "\t\t" << sizeof(longdvar) << endl;
- cout << "strvar1 \t" << &strvar1 << "\t\t" << sizeof(strvar1) << endl;
- cout << "strvar2 \t" << &strvar2 << "\t\t" << sizeof(strvar2) << endl;
- return 0;
- }
複製代碼 |