C 库宏 - NULL
C 语言教程
· 2019-02-23 12:58:01
描述
C 库宏 NULL 是一个空指针常量的值。它可以被定义为 ((void*)0), 0 或 0L,这取决于编译器供应商。
声明
下面是取决于编译器的 NULL 宏的声明。
#define NULL ((char *)0) 或 #define NULL 0L 或 #define NULL 0
参数
- NA
返回值
- NA
实例
下面的实例演示了 NULL 宏的用法。
#include <stddef.h>
#include <stdio.h>
int main ()
{
FILE *fp;
fp = fopen("file.txt", "r");
if( fp != NULL )
{
printf("成功打开文件 file.txt\n");
fclose(fp);
}
fp = fopen("nofile.txt", "r");
if( fp == NULL )
{
printf("不能打开文件 nofile.txt\n");
}
return(0);
}
假设文件 file.txt 已存在,但是 nofile.txt 不存在。让我们编译并运行上面的程序,这将产生以下结果:
成功打开文件 file.txt 不能打开文件 nofile.txt
点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html
The Algorithmic Beauty of Plants
Przemyslaw Prusinkiewicz、Aristid Lindenmayer / Springer / 1996-4-18 / USD 99.00
Now available in an affordable softcover edition, this classic in Springer's acclaimed Virtual Laboratory series is the first comprehensive account of the computer simulation of plant development. 150......一起来看看 《The Algorithmic Beauty of Plants》 这本书的介绍吧!