OK, I put together a little app to show how pointers work, to be uploaded to my website. However, getch() doesn't seem to be stopping the program unless I have two of them. It acts the same no matter where the first one is, but the 2nd one has to be just before return.
Using Dev-C++ on NT 4.
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
void foo(int *y);
int main(int argc, char *argv[])
{
int x = 100;
int *y = 0;
y = &x;
printf("Enter your number: ");
scanf("%d",&x);
printf("The value of x is: %d \n",x);
printf("The address if x is: %d \n",&x);
printf("The value of y is: %d \n",y);
printf("The value at that address is: %d \n",*y);
getch();
foo(y);
printf("The new value of x is: %d \n",x);
printf("The address if x is: %d \n",&x);
printf("The value of y is: %d \n",y);
printf("The value at that address is: %d \n",*y);
getch();
return 0;
}
void foo(int *y)
{
*y += 125;
}