Bugs Bugs
2013-12-06 11:26
211 查看
/***********Bug1*****************************************************************************/ int amount, curAmount, totalAmount; CString str; amount = atoi(X); curAmount = XX; totalAmount = XXX; str.Format( "%d %d %d", amount, curAmount, totalAmount ); //1 这里有可能会出错,无法通过,因为某处无法转换 char cBuf[256] = { 0 }; sprintf( cBuf, "%d %d %d", amount, curAmount, totalAmount ); //2 OK /***********Bug2*****************************************************************************/ int GetMoney( int &money ) { int cash; cash = 10000; money = cash; } int myMoney; GetMoney( myMoney ); //use myMoney //这里会出错,因为引用了局部变量
/***********Bug3*****************************************************************************/ //在字符串拷贝的时候 struct PkgStruct //报文格式 { char cActive[1]; //0: Not Active 1: Active char cMakeCardSn[20]; }; strcpy( pSt1->cActive, "1" ); //会使cMakeCardSn[0]有一个空字符0 strncpy( pSt1->cActive, "1", sizeof( pSt1->cActive ) ); //这样OK //strcpy会把字符串末尾的'\0'同时拷贝的,而当函数strlen发现'\0'即停止计算了,sizeof()则给出数组原先定义的大小
相关文章推荐
- spring 事物的传播方式以及隔离级别
- C# 生成xml文件
- Yii::app()疑惑
- Cygwin的安装和使用
- Unity3D的断点调试功能
- 几个输入输出函数的比较
- [转]IP地址-子网掩码-默认网关
- WPF控件模板
- 10 个免费的 C/C++ 集成开发环境
- sudo redirect
- easyui--验证表单提交后才开始验证的方法--form
- javascript基础知识
- IDC评述网:11月份海外域名主机服务商TOP10
- Hive安装与配置——深入浅出学Hive
- __bridge,__bridge_transfer和__bridge_retained详解
- tomcat启动,关于网络异常方面的建议!
- Libgdx专题系列:对象篇源码分析 TextureRegion
- window C++开发工具
- h264 Nalu 详解(转载) 及 sps.pps.idr相关
- 【分享】娱乐圈大V微博信息数据