Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop variables
#4
Damned! Sure, ā€œiā€ is 10 here. It gets clearer here (Korrektur, that is clearer):

Code: (Select All)

#include
#include

int main(void)
{
int i;

for (int i = 0; i < 5; i++)
{
printf("\n%2d", i);
}
printf("\n\n");

for (int i = 1; i < 5; i++)
{
printf("\n%2d", i);
}
//"i" is not initialized
printf("\n\n%2d", i);

//"i" is not initialized + 10
printf("\n\n%2d", i = i + 10);

printf("\n\n%2d", i = 10);
return(0);
}
Now "i" points to a memory address because it hasn't been assigned a value, plus 10. Yes, "i" is local.

[Image: Lokal.jpg]
Reply


Messages In This Thread
Loop variables - by Kernelpanic - 05-18-2024, 08:13 PM
RE: Loop variables - by DSMan195276 - 05-18-2024, 08:20 PM
RE: Loop variables - by SMcNeill - 05-19-2024, 07:45 PM
RE: Loop variables - by Kernelpanic - 05-18-2024, 08:43 PM
RE: Loop variables - by Kernelpanic - 05-18-2024, 09:55 PM
RE: Loop variables - by DSMan195276 - 05-19-2024, 12:43 AM
RE: Loop variables - by Kernelpanic - 05-19-2024, 07:22 PM
RE: Loop variables - by SMcNeill - 05-19-2024, 07:33 PM



Users browsing this thread: 1 Guest(s)