Hi. This is my first post. I'm a complete beginner with C, but have some ability with Python, and know a little Java.
Anyway, my problem involves while loops and pointers. I'm just getting the hang of pointers and have been making a few mess-around programs. One such program is supposed to iterate a pointer.
In the while loop, I expected the output to be 1,2,3,4...9. But it doesn't seem to loop. I don't know why. It compiles fine, but the output is simply 1. Then it stops.Code:int x; int *y; x = 500; //arbitrary value. y =&x; printf("%d", x); //print 500 printf("%d", y); // print memory space value. *y = 200; printf("%d",x); //print 200 //the above stuff is fine. Its the below while loop that I have a problem with. *y = 1; while( *y<10){ printf("%d",x); *y++ }
I'm sure I'm making a completely stupid mistake, but as a "N00b" can't figure out what is wrong.