LoginSignup
7
6

More than 5 years have passed since last update.

C言語の不思議な仕様

Last updated at Posted at 2013-03-11
#include <stdio.h>

int main(){
  (&puts)("&puts");
  (puts)("puts");
  (*puts)("*puts");
  (****puts)("****puts");

  return 0;  
}

怪しげで不自然だけど、正しいC言語ではコンパイルエラーにならない。
4つの puts はきちんと呼び出され、引数の文字列が標準出力に出る。

#include <stdio.h>

int main(){
  int a=12;
  int b={34};
  int c={{56}};
  printf( "%d %d %d\n", a, b, c );
  return 0;
}

こっちは今ひとつ自信がないけど、これもたぶん全部合法。
a, b, c は 12, 34, 56 で初期化される。

7
6
0

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
7
6