if (scanf("%d", &x) == NULL)
warning:comparison between pointer and
if (scanf("%d", &x) == NULL)
warning:comparison between pointer and
这是“NULL”在不同平台和编译器上面的定义:
/* A null pointer constant. */
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
因此为了去除编译警告,可以显示的加上:
if (scanf("%d", &x) == (int)NULL);
望采纳!!!