我无法处理ctime和“getch”。 C ++的conio.h,为什么? [英] I'm not being able to handle ctime and "getch" of conio.h of C++, why?

查看:115
本文介绍了我无法处理ctime和“getch”。 C ++的conio.h,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我在C ++中使用了code :: blocks,但我从来没有需要任何不同的用途,只需要声明ctime,time_t等等等等。除了包含conio.h和使用getch()分配char之外,我也不需要任何其他东西。它们从来都不是错误,并且在没有警告的情况下可以轻松地在我的控制台中使用
。但是,在visual studio中,他们创建了许多警告和相同代码的错误,这些代码在code :: blocks中运行之前没有任何错误,例如

While I used code::blocks for C++, I'd never needed any different uses than just declaring ctime, time_t blah blah blah. Nor did I need anything else other than including conio.h and using getch() assigning with a char. They were never errors and easily usable in my consoles without warnings. But, in visual studio they have created many warnings and errors of the same code which was run in code::blocks before without any errors, e.g.

Severity 代码
描述 项目
文件
抑制状态

错误 C4996
'ctime':此函数或变量可能不安全。请考虑使用ctime_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。有关详细信息,请参阅在线帮助。
SydTerminalOS c:\ usersrs \ syd the programmer \desktop \这个电脑(程序员)\ c ++ \c ++由visual studio \sydterminalos \sydterminalos \ manager.cpp提供的特殊应用程序
17

Severity Code Description Project File Line Suppression State
Error C4996 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. SydTerminalOS c:\users\syd the programmer\desktop\this pc (programmer)\c++\c++ special apps by visual studio\sydterminalos\sydterminalos\manager.cpp 17

严重性 代码
描述 项目
文件
抑制状态

错误 C4996
'getch':不推荐使用此项目的POSIX名称。而是使用符合ISO C和C ++的名称:_getch。有关详细信息,请参阅在线帮助。
SydTerminalOS c:\ usersrs \ syd the programmer \desktop \这个电脑(程序员)\ c ++ \c ++由visual studio \sydterminalos \sydterminalos \ manager.cpp提供的特殊应用程序
567

Severity Code Description Project File Line Suppression State
Error C4996 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _getch. See online help for details. SydTerminalOS c:\users\syd the programmer\desktop\this pc (programmer)\c++\c++ special apps by visual studio\sydterminalos\sydterminalos\manager.cpp 567

我是C ++和visual的新手工作室。请帮忙,好吗?

I'm new both in C++ and visual studio. Please help, will you?

推荐答案

你好Syndeed Ahnaf,

Hi Syndeed Ahnaf,

感谢您在此发帖。

>>错误 C4996
'ctime':此函数或变量可能不安全。请考虑使用ctime_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。有关详细信息,请参阅在线帮助。

SydTerminalOS c:\ usersrs \ thes programmer \desktop \这个电脑(程序员)\ c ++ \c ++特殊应用程序由visual studio \sydterminalos \sydterminalos \ manager.cpp

许多旧的CRT功能都有更新,更安全的版本。如果存在安全功能,则较旧的不太安全的版本被标记为已弃用,新版本具有
_s ("安全")后缀。在此上下文中,"弃用"是指"弃用"。只是意味着不建议使用函数;它并不表示该功能计划从CRT中删除。

Many old CRT functions have newer, more secure versions. If a secure function exists, the older, less secure version is marked as deprecated and the new version has the _s ("secure") suffix. In this context, "deprecated" just means that a function's use is not recommended; it does not indicate that the function is scheduled to be removed from the CRT.

有关详细信息,请参阅以下文档。

For more information, please refer to this document below.

< a href ="https://msdn.microsoft.com/en-us/library/8ef0s5kh.aspx"> https://msdn.microsoft.com/en-us/library/8ef0s5kh.aspx

>>错误 C4996
'getch':不推荐使用此项目的POSIX名称。而是使用符合ISO C和C ++的名称:_getch。有关详细信息,请参阅在线帮助。

SydTerminalOS c:\ usersrs \ thes programmer \desktop \这个电脑(程序员)\ c ++ \c ++特殊应用程序由visual studio \sydterminalos \sydterminalos \ manager.cpp

不推荐使用此POSIX函数。请改用符合ISO C ++标准的
_getch
。如果特定于实现的扩展要遵守C或C ++标准,则应使用以全局命名空间中的下划线开头的名称。

This POSIX function is deprecated. Use the ISO C++ conformant _getch instead. Implementation specific extensions should use names starting with an underscore in the global namespace if they want to adhere to the C or C++ Standard.

希望这可以为您提供帮助。

Hope this could be help of you.

最诚挚的问候,

Baron Bi

Baron Bi


这篇关于我无法处理ctime和“getch”。 C ++的conio.h,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆