用scanf读入string类型的变量

来源:互联网 发布:linux int 0x80 编辑:程序博客网 时间:2024/05/16 12:38

出处:http://blog.csdn.net/wxf2012301351/article/details/72455992

//编译环境:win7 64bit,  vs2013


步骤:


1、string tmp;//声明


2、tmp.resize(11);//限定大小


3、scanf("%s", &tmp[0]);//输入



输入数据中,超出指定个数的部分会被自动裁去


原创粉丝点击