摘要: 引用做参数时不能传一个定值(如数字或者const等~~~)somefunc(int& a = 4) -> default argument for ‘int& a’ has type ‘int’Is there a solution for it that isn't playing with pointers?My aim is to have a function that would take an int as a parameter by reference, but when no int is passed, a default int is giv 阅读全文
posted @ 2013-09-11 16:51 vanishfan 阅读(3169) 评论(0) 推荐(1) 编辑
摘要: sprintf的缓冲区溢出分类:技术2010-03-07 15:26362人阅读评论(0)收藏举报今天,调试sector的时候遇到一个特奇怪的问题,程序会在取string的c_str()的时候core掉,百思不得其解。仔细读了一下代码:string先用c_str()取过一次值,然后sprintf再次调用string的c_str,将字符串存在一个新的区域里面,这时候gdb了一下,发现在string比较长的时候,sprintf后的string的内存结构被破坏,好奇怪啊,怎么会被破坏了呢?找你几圈,发现罪魁就sprintf上面,原来是sprintf的缓冲区溢出,造成内存的破坏,天理啊!!解决方案是使 阅读全文
posted @ 2013-09-11 11:25 vanishfan 阅读(924) 评论(0) 推荐(0) 编辑