Code Fix

初級error: initialization of 'char' from 'char *' makes integer from pointer without a cast の原因と直し方 › パターン3

error: initialization of 'char' from 'char *' makes integer from pointer without a cast の原因と直し方

1文字を表すchar型の変数に、ダブルクォートで囲んだ文字列リテラルを代入しようとしたときに出るエラーです。

 1  #include <stdio.h>
 2  
 3  int main(void) {
 4      char sign = ___;
                     ^
 5      printf("%c\n", sign);
 6      return 0;
 7  }
main.c:4:17: error: initialization of 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]

空欄を埋めてコンパイル・実行を通す

広告
広告スロット(未設定)

error: initialization of 'char' from 'char *' makes integer from pointer without a cast の原因と直し方

シングルクォートとダブルクォートは別物です。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)