http://www.cnblogs.com/wanghao111/archive/2009/09/05/1560822.html

 1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5
6 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
7
8 int main(int argc, char** argv) {
9
10 string s;
11 char p[10];
12 char q[10];
13
14 //cin.getline(p,4);//最大只能接受3个字符,自动在末尾加上'\0'
15 cout<<"p="<<p<<endl;
16
17 cin.getline(q,3,'\0');//输入字符串以'\0' 结尾 ,大只能接受3个字符
18 cout<<"q="<<q<<endl;
19
20
21
22 getline(cin,s);
23 cout<<"s"<<s<<endl;
24
25 cout<<"p="<<p<<endl;
26 cout<<"q="<<q<<endl;
27 cout<<"s"<<s<<endl;
28 return 0;
29 }

最新文章

  1. Base64原理
  2. 学习 Local Sensitive Hash
  3. Web服务器之iis,apache,tomcat三者之间的比较
  4. NHibernate系列文章九:NHibernate对象二级缓存上
  5. 继续努力刷题--BE STRONGER AND STRONGER
  6. iOS-代理
  7. 一个简单的脚本让你的ubuntu14.04记忆屏幕亮度
  8. 用JS查看修改CSS样式(cssText,attribute(&#39;style&#39;),currentStyle,getComputedStyle)
  9. NUnit使用详解(一)
  10. jQuery动态效果实例
  11. 移动端Web开发如何处理横竖屏
  12. centos7 开机启动某些程序的方法
  13. swift2.0 UIImagePickerController 拍照 相册 录像
  14. 避免ssh断开导致运行命令的终止:screen
  15. Java NIO 学习总结 学习手册
  16. RobotFrame连接MySql数据库
  17. C++ 函数模板“偏特化”
  18. 设计模式のDecoratorPattern(装饰器模式)----结构模式
  19. JavaScript基础笔记(十)表单脚本
  20. lvs笔记

热门文章

  1. python画图的工具及网站
  2. 【行人惯性导航】关于行人导航中IMU位姿推导的知识点及相关代码
  3. SPOJ GSS8 - Can you answer these queries VIII | 平衡树
  4. hdu 2190 重建希望小学(数学,递推)
  5. 01_WPF概述
  6. Centos 7 端口聚合
  7. pycharm安装指导教程
  8. Linux内核 fork 源码分析
  9. SpringBoot之MultipartFile文件上传(6)
  10. JMeter 5.4 打开测试计划 报错:Unexpected error