读书笔记

 


在此处short为16位 有符号的最大数为32767 最小数为-327668。

hex 十六进制 oct  八进制

#include<iostream>
using namespace std;
int main()
{
	char code;
	cout<<"Enter your code:____\b\b\b\b";
	cin>>code;
	cout<<"you input "<<code<<endl;
	return 0;
}
\b 使光标回到第一个下划线处,输入多个字符后,只输出一个字符!!

cout 输出时不用指定输出类型,它会根据变量定义的类型进行输出!进行输出时只需<<变量名 即可 

float 的精度为6~7位,double为15~16位

%求模 生成第一个数除以第二个数的余数

当涉及两种运算类型时,较小的类型被转化为较大的类型。

"S" 字符串常量,表示两个字符,即S和\0字符。  而‘S’是字符常量 。

共用体可以用来存储多种类型的变量,条件是在不同的时间内进行,它的长度为其最大成员的长度。




如果给cout提供一个指针,它将打印地址。但如果指针的类型为char * ,则cout将显示指向的字符串。

#include <iostream>
#include <string>
using namespace std;
int main()
{
	int *p1=new int;
	*p1=10;
        char *p2="zonghua";
	cout<<p1<<"the number is:"<<*p1<<endl;
	cout<<p2<<endl;
	delete p1;
	return 0;
}
使用new创建动态结构

#include <iostream>
using namespace std;
struct good
{
	char name[20];
	float volume;
	double price;
};
int main()
{
	good *p=new good;
	cout<<"Enter name:";
	cin.get(p->name,20);
	cout<<"Enter volume:";
        cin>>p->volume;
	cout<<"Enter price:";
	cin>>p->price;
	cout<<(*p).name<<endl;
	cout<<p->volume<<endl;
	cout<<p->price<<endl;
	delete p;
	return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值