[C++] 用Xcode来写C++程序[3] Constants
用Xcode来写C++程序[3] Constants
以下是一些基本数据的含义:
75 // int
75u // unsigned int
75l // long
75ul // unsigned long
75lu // unsigned long
3.14159 // 3.14159
6.02e23 // 6.02 x 10^23
1.6e-19 // 1.6 x 10^-19
3.0 // 3.0
3.14159L // long double
6.02e23f // float
'z'
// 单个字符
"How do you do?"
// 字符串
一些符号的含义:
bool类型以及指针
bool foo = true;
bool bar = false;
int* p = nullptr;
const变量
#include <iostream> using namespace std; const double pi = 3.14159; const char newline = '\n'; int main () { double r=5.0; // radius double circle; circle = 2 * pi * r; cout << circle; cout << newline;
宏定义:
#include <iostream> using namespace std; #define PI 3.14159 #define NEWLINE '\n' int main () { double r=5.0; // radius double circle; circle = 2 * PI * r; cout << circle; cout << NEWLINE; }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步