c++ - function in c++ why my compiler didn't recognize the error()
问题描述
getting error using error() function in c++.
my problem is when i wanted to include the error() function to my code i get compilation errors.
it seems that the compiler does not recognize this function.
int some_function(){
double input{0};
cin>>input;
if(!cin){
error("couldn't read double in 'some_function()'");
return -1;
}
i expected the message "couldn't read double in 'some_function()'" when i input for example a string.
解决方案
There is no error
function in the C++ standard library. Your compiler doesn't "recognize" this function because it doesn't exist.
Why do you think there should be such a function?
If you want to print an error message in C++, the usual method is to use the cerr
stream:
std::cerr << "couldn't read double in 'some_function()'\n";
推荐阅读
- node.js - 为什么我连接不上猫鼬服务器
- c# - 如何根据DependencyProperty设置DataRowView的背景颜色?
- firebase - Crashlytics 不适用于即时应用程序
- javascript - Inline-videos don't play when direct URLs are pasted into URL bar in Google Chrome
- list - 如何从可能包含 Racket 列表的列表中删除重复项
- hql - JPQL QuerySyntaxException:意外的令牌——Jhipster
- javascript - 键盘事件:Keyup 给出不一致的行为
- javascript - 日期范围选择器和计算器
- amazon-web-services - 将 AWSGlue 用作 Hive Metastore,其中数据位于 S3 中
- python-3.x - 如何在集群 (qsub) 中重新启动失败的 PBS 作业?