1. Output like printf ()
%a,%a read in a floating-point value (valid only C99)
%c reads in one character
%d read-in decimal integer
%i read in decimal, octal, hexadecimal integer
%o Read in octal integer
%x,%x read in hexadecimal integer
%s reads a string, ending with a space, tab, or line break.
%f,%f,%e,%e,%g,%g is used to enter real numbers, which can be entered in decimal or exponential form.
%p read in a pointer
%u read in an unsigned decimal integer
%n the equivalent number of characters that have been read into the value
%[] Scan Character Set
Percent Read% sign
2. Output like cout<<
Note: However, when you output a qstring string, double quotes are automatically added.
Code:
#include<QDebug>int main(){ int a; char b; QString s = QString("hello world"); qDebug()<<"s:"<<s; s.sprintf("%d %c",a=2,b=‘b‘); //格式化字符串 qDebug("s:%d",a); //格式化输出 return0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Output with Qdebug