Don't guess I will be getting any points for attention to detail tonight.
Yes the cut and paste worked fine. I had left the semi-colon off the end of the definition. The compiler is on an offline computer and I hurriedly copied from memory. I put your snippet on a thumb drive and took it to the other machine to check it out. I did not do that when posting the example problem; another mistake. Also I should have known to look at the line before where the compiler said it was.
It will come back to me a day or two. It is amazing how fast I become rusty.
Thanks again,
gtb
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually my post solved three problems: the extra = sign in the definition of the struct, the missing array brackets [] in myStruct, and the missing semicolon at the very end. I'm assuming that since you have two groups of two floats in your myStruct, you want it to be an array and not a single instance.
Try pasting my code into your program and see if it compiles.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Greetings,
I get the message
"two or more data types in definition of myStruct" with the following example.
main()
{
struct typeMyStruct = {
float a;
float b;
};
struct typeMyStruct myStruct = {
{1.0, 2.0},
{3.0, 4.0}
}
}
Hmmm,
Don't guess I will be getting any points for attention to detail tonight.
Yes the cut and paste worked fine. I had left the semi-colon off the end of the definition. The compiler is on an offline computer and I hurriedly copied from memory. I put your snippet on a thumb drive and took it to the other machine to check it out. I did not do that when posting the example problem; another mistake. Also I should have known to look at the line before where the compiler said it was.
It will come back to me a day or two. It is amazing how fast I become rusty.
Thanks again,
gtb
I'm not sure, but I think this is what you want:
struct typeMyStruct {
float a;
float b;
};
struct typeMyStruct myStruct[] = {
{1.0, 2.0},
{3.0, 4.0}
};
The first struct line defines the type, and the second struct line defines an array of two of those structs.
Doh! How stupid of me.
Thanks.
Sorry for the sloppy post. Now I have removed the offending = from my example and this is the code that causes the error.
main()
{
struct typeMyStruct {
float a;
float b;
};
struct typeMyStruct myStruct = {
{1.0, 2.0},
{3.0, 4.0}
}
}
Actually my post solved three problems: the extra = sign in the definition of the struct, the missing array brackets [] in myStruct, and the missing semicolon at the very end. I'm assuming that since you have two groups of two floats in your myStruct, you want it to be an array and not a single instance.
Try pasting my code into your program and see if it compiles.