Description of printf() function in Keil C51

Publisher:神秘行者Latest update time:2019-01-17 Keywords:Keil Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In C51, when using the printf() function for formatted output, the format control characters are different from those in ANSI C.


In the format control characters, b stands for byte


Output uint8_t in decimal: %bu


Output int8_t in decimal: %bd




#include

 

void tst_printf (void) {

  char a = 1;

  int b = 12365;

  long c = 0x7FFFFFFF;

 

  unsigned char x = 'A';

  unsigned int y = 54321;

  unsigned long z = 0x4A6F6E00;

 

  float f = 10.0;

  float g = 22.95;

 

  char buf[] = "Test String";

  char *p = buf;

 

  printf ("char %bd int %d long %ld\n",a,b,c);

  printf ("Uchar %bu Uint %u Ulong %lu\n",x,y,z);

  printf ("xchar %bx xint %x xlong %lx\n",x,y,z);

  printf ("String %s is at address %p\n",buf,p);

  printf ("%f != %g\n", f, g);

  printf ("%*f != %*g\n", (int)8, f, (int)8, g);

}


Keywords:Keil Reference address:Description of printf() function in Keil C51

Previous article:C51/C52 Interrupt (EXTI)
Next article:51 MCU - Storage

Recommended ReadingLatest update time:2024-11-15 07:46

Learning the Basics of C51 3 "Keywords and Identifiers"
3 Keywords and Identifiers     3.1 Keywords Keywords     are words that are used by Turbo C2.0 itself and cannot be used for other purposes. For example, keywords cannot be used as variable names, function names, etc.     Turbo C2.0 has the following keywords:     11 keywords extended by Turbo C2.0      asm _cs
[Microcontroller]
c51: Delay Program
#include   #define uchar unsigned char   //f=11.0592   void delay(uchar ms) //about n (ms) delay {    int i;     while(ms--)    {       i=97;   while(i--); //Loop once for about 1ms    } }     main() {      delay(1);      delay(5);    delay(10);      delay(100);    
[Microcontroller]
Application of Operators in C51 Programming
Prioritization: 1. The highest priority: not really an operator    () Symbols that change priority (parentheses), Grou PIN g operator     Array subscript operator Array a CC ess     () function call operator function access      - Struct member selection operator (I call it "arrow") member access from a pointer     
[Microcontroller]
"Beginner's C51 Self-study Notes" - Flowing Light Implementation (Bus Operation)
#include reg52.h #define uchar unsigned char //macro definition #define uint unsigned int   unsigned char table ={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//11111110,11111101,11111011..... /*     Delay */ void delay(void) { uchar a,b; for(a=0;a 200;a++) for(b=0;b 200;b++); }   void main() { uchar i; while(1
[Microcontroller]
(C51 Learning 2) Light up the digital tube
1. What is a digital tube? As shown in the picture, this is a two-digit digital tube A digital tube should have 8 LED lights to control what number it displays, 7 LEDs to control the number, and 1 LED to control the decimal point. 2. Common cathode and common anode As shown in the figure above, for a digit
[Microcontroller]
(C51 Learning 2) Light up the digital tube
Absolute address positioning of KEIL C51
For MCU space allocation, see *.M51 file. For ARM and DSP space allocation, see *.map file.   1. Function location: If you want to place the function int BIN2HEX(int xx) {     ... } in the C source file tools.c at 0x1000 in CODE MEMORY, compile the project first, then open the M51 file of the projec
[Microcontroller]
Why can't I find absacc.h in the keil software? How can I find it?
Save the following content as absacc.h: The reason is that the higher version of KEIL has been optimized and many previous library files have been removed, so users need to add them manually #ifndef __ABSACC_H__ #define __ABSACC_H__ #define CBYTE ((unsigned char volatile code *) 0) #define DBYTE
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
Introduction: Let me first explain that the chip driver of the LCD1602 I am going to talk about below is HD44780. If your LCD1602 driver chip is not HD44780, then the following content is not applicable. This time I will share my LCD1602 programming experience: Let me first explain that the chip driver of the LCD160
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号