cprintf
v1.0.60
Published
c like printf and sprintf
Downloads
74
Readme
cprintf
cprintf supported this env
- nodejs
- broswer
- webchat app
install via npm
npm install cprintf --save
this lib include two functions
string sprintf(strFormat , ...);
void printf(strFormat , ...);
usage
// import function
const sprintf = require('cprintf').sprintf;
const printf = require('cprintf').printf;
// c-like printf
printf('hellp prinf %d\n' , 1 );
// c-like sprintf
var strText = sprintf('hellp prinf %d\n' , 1 );
printf( strText );
console.log( strText );
// direct printf a JSON object
var xxObj = {a : 1 , b : 2};
printf( "%s" , xxObj);
support formats just like c printf and sprintf
- %c -- ascii value
- %d -- signed number
- %s -- string
- %x -- number in hex
- %i -- signed number
- %f -- float
- %o -- octal number
- %u -- unsigned number