I'm trying to make a program that has a function that gets an int and using pointers increases the int by 1.
This is what i was trying to do but it doesn't work...
#include <stdio.h>
#include <stdlib.h>
void inc(int x);
int main()
{
int x = 0;
printf("Please enter a number : ");
scanf("%d", &x);
printf("The value of 'x' before the function is - '%d'\n", x);
inc(x);
printf("The value of 'x' after the function is - '%d'\n", x);
system("PAUSE");
return 0;
}
void inc(int x)
{
int* px = &x;
*px = x + 1;
}