Afficher un message
Vieux 31/01/2008, 16h11   #14
Army1987
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: declaration of variable in for loop

poornimamprabhu wrote:

> Hi there,
>
> suppose i have piece of code like
> main()
> {
> int i,j;
> for(i=0;i<10;i++){
> int k = i;
> printf("%d %p = *%d\n",i,&k,k);
> }
> }
>
>
> When i see the address of K its same in all iterations.That means K is
> only defined once at a time.

The compiler *is* allowed to place k in a different place each time, but,
why should it?

--
Army1987 (Replace "NOSPAM" with "email")
  Réponse avec citation
 
Page generated in 0,04329 seconds with 9 queries