Jump to content
  • Advertisement
Sign in to follow this  
MSalley

wierd error

This topic is 4845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
Your compiler might give you that error message if you forgot a semi-colon in a class/struct declaration before your profiles declaration.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

// 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;

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!