wierd error

Started by
5 comments, last by MSalley 18 years, 8 months ago
struct profiles{
       char name[30];
       address profile_address;
       contact_info profile_contact_info;
       }profile_one;
Brings up error message: two or more data types in declaration of 'profile_one' Help!
-Mat² §alley©-
Advertisement
Your compiler might give you that error message if you forgot a semi-colon in a class/struct declaration before your profiles declaration.
I believe it should be typedef struct, since you put an alternative name at the end.
Quote:Original post by pichu
I believe it should be typedef struct, since you put an alternative name at the end.

Quoted for truth.

It's worth noting though that, at least in my opinion, it is heinous to tag instances on the end of the declaration of a struct. It's just plain ugly. I would be filled with ungodly power and smite the man who would leave me code with that sort of thing scattered in it [grin]
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
What's a typedef struct?
-Mat² §alley©-
// instead of:struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;       }profile_one;// use:typedef struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;} profile_one;// However, you should really use neither of those, rather:struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;};profiles profile_one;
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
If I try the one you recommended, it says 'multiple types in one declaration'.


Okay, nevermind, I got it, thanks to all. I had thought that

Struct example{
//elements here
}

didn't need a semicolon after the } if it didn't have instances at the end, so the error was actually in the structs above the 'profiles' struct.


[Edited by - MSalley on August 10, 2005 6:03:51 PM]
-Mat² §alley©-

This topic is closed to new replies.

Advertisement