C 库宏 - EDOM

C 语言教程 · 2019-02-22 22:59:39

描述

C 库宏 EDOM 表示一个域错误,它在输入参数超出数学函数定义的域时发生,errno 被设置为 EDOM。

声明

下面是 EDOM 宏的声明。

#define EDOM some_value

参数

  • NA

返回值

  • NA

实例

下面的实例演示了 EDOM 宏的用法。

#include <stdio.h>
#include <errno.h>
#include <math.h>

int main()
{
   double val;

   errno = 0;
   val = sqrt(-10);
   if(errno == EDOM) 
   {
      printf("Invalid value \n");
   }
   else 
   {
      printf("Valid value\n");
   }
   
   errno = 0;
   val = sqrt(10);
   if(errno == EDOM) 
   {
      printf("Invalid value\n");
   }
   else 
   {
      printf("Valid value\n");
   }
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

Invalid value
Valid value

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Foundation Web Standards

Foundation Web Standards

Jonathan Lane、Steve Smith / Friends of ED / 21st July 2008 / $34.99

Foundation Web Standards explores the process of constructing a web site from start to finish. There is more to the process than just knowing HTML! Designers and developers must follow a proper proces......一起来看看 《Foundation Web Standards》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

html转js在线工具
html转js在线工具

html转js在线工具