Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C Struct pointer as Parameter

I'm trying to pass a pointer to a struct in C but i cannot:

float calcular_media(struct aluno *aluno) {

Output warning:

C:\WINDOWS\system32\cmd.exe /c gcc main.c aluno.c
aluno.c:7:29: warning: 'struct aluno' declared inside parameter list

What am I doing wrong? Thank you.

like image 976
johnreli Avatar asked Feb 17 '26 20:02

johnreli


1 Answers

In the file containing the line

float calcular_media(struct aluno *aluno) {

one of the following must be there before the line

  • struct declaration: e.g. struct aluno; or
  • struct definition: e.g. struct aluno { char c; int i; double d; }; or
  • include of some header file which has one of the above: e.g. #include "aluno.h"

like image 148
Arun Avatar answered Feb 19 '26 14:02

Arun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!