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;
}
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;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks efn, I knew it was somthing small.
typedef struct myModel{
char myChar;
int myInt;
double myDouble;
}