Link to home
Start Free TrialLog in
Avatar of mistagitar
mistagitar

asked on

returning structure from function

Compiler error:  "two or more data types in declaration of readData"

The point of data structures is to have objects of various data types right?  I'm guessing a simple syntax error.....


#include<stdio.h>

struct myModel{
    char myChar;
    int myInt;
    double myDouble;
}

struct myModel readData(){
    struct myModel data;
    data.myChar = 'a';
    data.myInt = 1;
    data.myDouble = 5.00;
    return data;
}

int main(){
    struct myModel test = readData();
    return 0;
}
Avatar of shivsa
shivsa
Flag of United States of America image

i think u have to declare like this.

typedef struct myModel{
    char myChar;
    int myInt;
    double myDouble;
}
ASKER CERTIFIED SOLUTION
Avatar of efn
efn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mistagitar
mistagitar

ASKER

Thanks efn, I knew it was somthing small.