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

Mark L Pappin wrote:
> 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


Yes, I mistyped the name of the variable

Thanks


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
  Réponse avec citation
 
Page generated in 0,05363 seconds with 9 queries