C Tutorial/printf scanf/printf conversion


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

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