c - Calling Struct to main function from header file -
c - Calling Struct to main function from header file -
i have 2 header files , main program.
header files data.h , flight.h. main  programme calculateflight.c.
the   info header file has set of typedef structs contains variables  required  programme run.
i have created headerfile named flightmodel.h contains following:
#ifndef __flight_model_h #define __flight_model_h #include "data.h"  void calculateflight(speedparamstype *speed, spinparamstype *spin,                      flightparamstype *fdata);  #endif    the data.h contains typedef structs like
typedef struct {   float totalspin;   float spinaxis;   float backspin;   float sidespin; } spinparamstype;    there no errors in struct variables, don't know how  phone call struct  within main function.
    void main() {      speedparamstype speed;      spinparamstype spin;      flightparamstype fdata;      speed.totalspeed=200.0f;      speed.launchangle=30.0f;      speed.horizontalangle=5.0f;      spin.totalspin=1000.0f;      flightparamstype fdata;      fdata.carry=      calculateflightmodel(&speed,&spin,&fdata);      getch(); }    this have done in main function.it shows error c2275: 'flightparamstype' : illegal utilize of type look see declaration of 'flightparamstype'; syntax error : missing ';' before identifier 'fdata'
here's 1  illustration of usage, note besides #include directive, there's  nil special needs done.
#include "flight.h"  int main(int argc, char *argv[]) {    spinparamstype = {1.0f, 1.0f, 1.0f, 1.0f};    spinparamstype b = {2.0f, 2.0f, 2.0f, 2.0f};    flightparamstype c; // don't know kind of members struct have.     calculateflight(&a, &b, &c);       homecoming 0; }    remember compile source code files , link them together
 c struct 
 
Comments
Post a Comment