Afficher un message
Vieux 31/01/2008, 14h05   #11
Mark L Pappin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
 
Page generated in 0,04984 seconds with 9 queries