芯片:CH583
代碼
????????static?char?xxx[10]={"3.14"}; ????????float?pi; ????????char?fbuf[20]; ????????DBG("x?=?%s\n",xxx); ????????sscanf(xxx,"%f",&pi); ????????sprintf(fbuf,"%.2f",pi); ????????DBG("pi?=?%.2f\n",pi); ????????DBG("fbuf?=?%s\n",fbuf); ????????float?rlt?=?strtof(xxx,?NULL); ????????sprintf(fbuf,"%.2f",rlt); ????????DBG("rlt?=?%.2f\n",rlt); ????????DBG("fbuf?=?%s\n",fbuf); ????????float?fpi?=?3.14; ????????sprintf(fbuf,"%.2f",fpi); ????????DBG("fpi?=?%.2f\n",fpi); ????????DBG("fpi*100?=?%d\n",(int)(fpi*100)); ????????DBG("fbuf?=?%s\n",fbuf);
DBG宏的實(shí)現(xiàn)
#define?DBG(...)?printf("?DBG(%s,?%s(),?%d):?",?__FILE__,?__FUNCTION__,?__LINE__);?printf(__VA_ARGS__)
打印結(jié)果
?DBG(../src/Main.c,?main(),?749):?x?=?3.14 ?DBG(../src/Main.c,?main(),?752):?pi?=?26815622256785016688296265592222112551708132452936578279936498398813364362571671098643215977672002762693733515732368436221370366071748541264718157228015616.00 ?DBG(../src/Main.c,?main(),?753):?fbuf?=?2.00 ?DBG(../src/Main.c,?main(),?756):?rlt?=?26815615859885384735558591743984408416899026634245440356407978903749122491113867963109291794919019276406862025209102462237971718664841348387476629572550656.00 ?DBG(../src/Main.c,?main(),?757):?fbuf?=?2.00 ?DBG(../src/Main.c,?main(),?760):?fpi?=?26815615859885384735558591743984408416899026634245440356407978903749122491113867963109291794919019276406862025209102462237971718664841348387476629572550656.00 ?DBG(../src/Main.c,?main(),?761):?fpi*100?=?314 ?DBG(../src/Main.c,?main(),?762):?fbuf?=?2.02
c 庫(kù)選擇
熱門產(chǎn)品 :
USB3.0 HUB控制器:CH634