Link to home
Start Free TrialLog in
Avatar of zizi21
zizi21

asked on

pls help - declaring a register variable

hi,
i am trying to declare a register variable

register int a = (int *)malloc(z*sizeof(int));

the error that i get is register name not specified for a ..


Avatar of AriMc
AriMc
Flag of Finland image

Please provide the complete error message. Also it would be helpful to know why you want a pointer to be a register variable.

void function (void)
{
register int a;
for (a = 0; a < 10;a++)
 {
   printf ("%d", a); \\ Prints numbers 0 to 9

 }
}
Avatar of Deepu Abraham

if you are type casting to int* then you need to write like this:

register int* a = (int*)malloc(z*sizeof(int));

else

register int  a = malloc(z*sizeof(int));

Hope these link will clear your doubts:
http://geeksforgeeks.org/?p=4346
ASKER CERTIFIED SOLUTION
Avatar of Deepu Abraham
Deepu Abraham
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial