为什么在c语言中使用gets函数是危险的
语言 函数 为什么 危险 使用
2023-09-27 14:28:10 时间
If you have code like this:
and you type in more than 10 characters when the program is run, you will overflow the buffer, causing undefined behaviour. The gets() function has no means of preventing you typing the characters and so should be avoided. Instead you should use fgets(), which allows you to limit the number of characters read, so that the buffer does not overflow.:
|
相关文章
- 为什么说Python是一门动态语言--Python的魅力
- linux c语言 select函数使用方法
- Spring表达式语言 之 5.1 概述 5.2 SpEL基础(拾叁)
- 请用简单的语言描述数组方法pop(),push(),unshift(),shift()
- 《R语言数据挖掘》----1.12 数据集成
- c语言之 malloc函数详解 在堆中动态分配内存malloc和new的区别
- go语言中strings包中的Trim函数的作用是什么
- 第二十三节:Java语言基础-详细讲解函数与数组
- Swift语言精要 - 浅谈代理模式(Delegate)
- GUI(UI编程)语言与面向对象、dsl
- 基于原型的js语言
- GO语言练习:多返回值函数
- GO语言练习:构建json 和 解析JSON 实例
- QT in VS 多语言实现(中英文切换,每个步骤都有截图,只有UTF8才能让Qt语言家正确读取。先qApp->removeTranslator,然后installTranslator,每个类都要写上槽函数RetranslateUI)
- 《Python语言程序设计》——1.9 开始学习图形化程序设计
- 《Python语言程序设计》——3.2 常见的Python函数
- 计算机语言学习导论[C/C++]
- 一文带你搞懂Go语言函数选项模式,Go函数一等公民。
- 网站如何知道浏览器的用户在使用什么语言?
- c程序设计语言_习题1-19_编写函数reverse(s)将字符串s中字符顺序颠倒过来。
- c程序设计语言_习题1-16_自己编写getline()函数,接收整行字符串,并完整输出
- c语言中的main函数讨论
- Lisp 家族迎来新成员,函数式语言 Lux 是什么?