Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm try to make an payroll program in c++. In the beginning of my program I have to define a struct called EmployeeT that will store all the information about an employee together in one unit.

Then I have to take all that information and put it in an array of EmployeeT structures called employees.

I have this so far...

typedef struct 
{
  char name[];
  char title;
  double gross;
  double tax;
  double net;
}  EmployeeT;

So, What am I miss or doing wrong?

Thanks guys

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
676 views
Welcome To Ask or Share your Answers For Others

1 Answer

What you have there is fine, except that if you want a flexible array member (char name[]), it needs to be the last field in the structure. Probably what you really want is a pointer (char *name) or a real array (char name[SOME_SIZE]), though.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...