Mega Code Archive

 
Categories / C Tutorial / Printf Scanf
 

Using the p, n, and % conversion specifiers

#include <stdio.h> int main() {     int *ptr;    int x = 12345;    int y;                ptr = &x;         printf( "The value of ptr is %p\n", ptr );    printf( "The address of x is %p\n\n", &x );    printf( "Total characters printed on this line:%n", &y );    printf( " %d\n\n", y );    y = printf( "This line has 28 characters\n" );    printf( "%d characters were printed\n\n", y );        printf( "Printing a %% in a format control string\n" );    return 0; } The value of ptr is 9a378 The address of x is 9a378 Total characters printed on this line: 38 This line has 28 characters 28 characters were printed Printing a % in a format control string