Use scanf() to get input values for a pointer that already contains an address - C Pointer

C examples for Pointer:Address

Description

Use scanf() to get input values for a pointer that already contains an address

Demo Code

#include <stdio.h>

int main(void)
{
  int value = 0;//from   w w  w .j  a  v  a2 s.  c om
  int *pvalue = &value;                     // Set pointer to refer to value

  printf ("Input an integer: ");
  scanf(" %d", pvalue);                   // Read into value via the pointer

  printf("You entered %d.\n", value);       // Output the value entered
  return 0;
}

Result


Related Tutorials