3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C言語 「NULL」、「'\0'」、「0」の比較

Last updated at Posted at 2020-03-10

実行環境によって値が変わることはあると思うのであくまで参考まで
NULLは「(void*)0」なので、値を出力すること自体、良くないことですが、やってみています。

# include<stdio.h>

int main (void) {
    printf("数字\n");
    printf("%d\n", NULL);
    printf("%d\n", '\0');
    printf("%d\n", 0);

    printf("アドレス\n");
    printf("%p\n", NULL);
    printf("%p\n", '\0');
    printf("%p\n", 0);

    printf("メモリ\n");
    printf("%lu\n", sizeof(NULL));
    printf("%lu\n", sizeof('\0'));
    printf("%lu\n", sizeof(0));

    return 0;
}
数字
0
0
0
アドレス
0x0
0x0
0x0
メモリ
8
4
4
3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?