Re: declaration of variable in for loop
jacob navia <jacob@nospam.com> writes:
> main()
> {
> int i,j, *pint;
> for(i=0;i<10;i++){
> int k = i;
> printf("%d %p = *%d\n",i,&k,k);
> pint=&i;
> }
> *pint = 789; // Accessing illegal storage
What's illegal about it?
If the last statement inside the loop body had instead been
pint=&k;
then you might have a point.
mlp
|