strcpy和strcpy_s

太之初一 posted @ 2016年5月06日 16:21 in C++ with tags 基础 C++ Windows , 1214 阅读

我在做Windows程序设计课程实验的时候,参照书上的例子使用了strcpy,结果VS报错说这个函数不安全,应该使用strcpy_s。

两者有什么区别呢?其实是因为strcpy无法判断他的操作对象是否有足够的缓冲区,若缓冲区不够的话,就会发生溢出。

strcpy_s避免了这个问题。它会显式地向你报告缓冲区不足的错误,避免丈二和尚摸不着头脑。

Avatar_small
MP XII Exam Pattern 说:
2022年8月17日 20:38

Madhya Pradesh Board Of Secondary Education Was Established in 1965 With The Aim Of Serving Best Quality Education to Their Students the Board Of Education Provide MP Board 12th Model Paper 2022 Madhya Pradesh Board MP 12th Class Question Paper in Pdf, MP XII Exam Pattern 2022 Click to Download for English MP Board 12th Model Paper Of English MP Board 12th Model Paper for Science MPBSE Science Sample Paper 12th,


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter