register variable???
Sungkee Lee
sklee at pompeii.SRC.Honeywell.COM
Sat Sep 9 02:35:32 AEST 1989
#include <stdio.h>
int list[5] = {0, 1, 2, 3, 4};
main()
{
register int i;
printf("list = %d %d %d %d %d\n",
list[0], list[1], list[2], list[3], list[4]);
i = 0;
while (i < 4) list[i] = list[++i];
printf("list = %d %d %d %d %d\n",
list[0], list[1], list[2], list[3], list[4]);
}
Above program gave me the result,
list = 0 1 2 3 4
list = 0 1 2 3 4.
However, if I define "int i" instead of "register int i",
the result is
list = 0 1 2 3 4
list = 1 2 3 4 4.
Is this the way register variable is designed?
Or, is this compiler error? I ran this program on Sun 3/60?
More information about the Comp.lang.c
mailing list