C examples for Language Basics:scanf
scanf( ) with %n stores the number of characters read from the input up to where the %n was encountered into the integer variable pointed to by the corresponding argument.
#include <stdio.h> int main(void) { char *p;//from w ww .j av a 2 s . c o m int n; printf("Enter an address: "); scanf("%p %n", &p, &n); printf("%d", n); return 0; }