Code Fix

上級error: invalid type argument of '->' の原因と直し方 › パターン1

error: invalid type argument of '->' の原因と直し方

構造体そのものの変数に対して->を使おうとしたときに出るエラーです。

 1  #include <stdio.h>
 2  
 3  struct Point { int x; };
 4  
 5  int main(void) {
 6      struct Point a = {5};
 7      printf("%d\n", ____);
                         ^
 8      return 0;
 9  }
main.c:7:21: error: invalid type argument of '->' (have 'struct Point')

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

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

error: invalid type argument of '->' の原因と直し方

->は構造体へのポインタ専用の演算子です。

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

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