For example:
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int x;
int *ptr;
ptr = &x;
printf("Gimme a number: ");
// always check to make sure that what was
// input was what was required
if(scanf("%d", ptr) == 1)
{
printf("You input: %d\n", *ptr);
} else
{
printf("failed to read integer.\n");
}
// if you don't care about the scanf return code
// then casting it to void should work
// but it doesn't with gcc
// (void) scanf("%d", ptr); // or
// scanf("%d", &x);
getchar();
return 0;
}
The comments explain where I'm at with this.