Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,603 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 947 people online right now. Registration is fast and FREE... Join Now!




Record

 
Reply to this topicStart new topic

Record, record of employee

qaz1134
post 30 Jun, 2008 - 09:22 AM
Post #1


D.I.C Head

**
Joined: 21 May, 2008
Posts: 60



Thanked 1 times
My Contributions


hello guys please again helpme on this one
i really dont know what gone wrong and i have too many errors 25 for the exact
i think i need help
CODE

#include<stdio.h>
#include<conio.h>
#define Max 50
typedef str20, char[20];
struct mystruct {
str20 lname, fname;
char mi;
int NHW;
float RPH;
}EmpRec;

struct mystruct EmpRec[Max];
void main()
{
int i;
for (i=0;i<Max;i++)
{
printf("Enter last nam:\t");
gets(EmpRec[i].lname);
printf("Enter last name:\t");
gets(EmpRec[i].fname);
printf("enter middleinitial:\t");
EmpRec[i].mi=getche();
printf("enter the no. of hr worked");
scanf("%d",&NWH);
printf("enter rate/hr");
scanf("%d",&RPH);
}
for (i=0;i<Max;i++)
{
printf("last name is:\t",EmpRec[i].lname);
printf("first name is:\t",EmpRec[i].fname);
printf("MI is%ch\t",EmpRec[i].mi);
printf("No. of hr worked:%d\t",EmpRec[i].NWH);
printf("Rate/hr is:%d\t",EmpRec[i].RPH);
}
getch();
}


i really appreciate your help!!!
User is offlineProfile CardPM

Go to the top of the page

Cerolobo
post 30 Jun, 2008 - 11:19 AM
Post #2


D.I.C Regular

Group Icon
Joined: 5 Apr, 2008
Posts: 440



Thanked 31 times
My Contributions


typedef str20, char[20]; is incorrect. Type define uses the exact same syntax as variable deceleration. The only difference, is that the identifier becomes a alias for that data type.

char foo[20]; // Array of 20 characters
typedef char str20[20]; // str20 is now a alias for a array of 20 characters
str20 bar; // Same type as foo
User is offlineProfile CardPM

Go to the top of the page

qaz1134
post 3 Jul, 2008 - 08:26 AM
Post #3


D.I.C Head

**
Joined: 21 May, 2008
Posts: 60



Thanked 1 times
My Contributions


QUOTE(Cerolobo @ 30 Jun, 2008 - 12:19 PM) *

typedef str20, char[20]; is incorrect. Type define uses the exact same syntax as variable deceleration. The only difference, is that the identifier becomes a alias for that data type.

char foo[20]; // Array of 20 characters
typedef char str20[20]; // str20 is now a alias for a array of 20 characters
str20 bar; // Same type as foo







thank you very much!!!!

you mean like this??????
typedef char str20[30];
User is offlineProfile CardPM

Go to the top of the page

Cerolobo
post 3 Jul, 2008 - 09:44 AM
Post #4


D.I.C Regular

Group Icon
Joined: 5 Apr, 2008
Posts: 440



Thanked 31 times
My Contributions


Yes, that should work. Although, I now find the name misleading, since you moved from a array of 20 chars to 30.
User is offlineProfile CardPM

Go to the top of the page

qaz1134
post 20 Jul, 2008 - 04:14 AM
Post #5


D.I.C Head

**
Joined: 21 May, 2008
Posts: 60



Thanked 1 times
My Contributions


QUOTE(Cerolobo @ 3 Jul, 2008 - 10:44 AM) *

Yes, that should work. Although, I now find the name misleading, since you moved from a array of 20 chars to 30.




sorry i forgot to say thank you!!! biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 02:13AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month