当前位置:网站首页>Sprintf formatter abnormal exit problem
Sprintf formatter abnormal exit problem
2022-07-03 04:49:00 【*_ Look up at the starry sky_*】
Use sprintf Formatter exception
static char logfileBuf[1024] = {
0};
sprintf(logfileBuf, "<%d ms>[%s:%d %s] %s", time, __FILE__, __LINE__, __FUNCTION__, buf);
Format output directly to logfileBuf Abnormal exit of program
At first, I thought it would be logfileBuf The buffer is too small , It still exits abnormally after increasing
Debugging takes a long time to find a solution
char fileBuf[512] = {
0};
char lineBuf[100] = {
0};
char funcBuf[100] = {
0};
char timeBuf[100] = {
0};
sprintf(timeBuf, "<%lld ms>", time);
sprintf(fileBuf, "%s", __FILE__);
sprintf(lineBuf, "%d", __LINE__);
sprintf(funcBuf, "%s", __FUNCTION__);
sprintf(logfileBuf, "%s[%s:%s %s] %s", timeBuf, fileBuf, lineBuf, funcBuf, buf);
Format step by step first __FILE__、__LINE__ these , Finally, format it uniformly to logfileBuf.
边栏推荐
- [BMZCTF-pwn] 20-secret_ file
- Pyqt control part (II)
- Priv app permission exception
- document. The problem of missing parameters of referer is solved
- How to choose cross-border e-commerce multi merchant system
- 2022 a special equipment related management (elevator) analysis and a special equipment related management (elevator) simulation test
- [SQL injection point] location and judgment of the injection point
- Valentine's day limited withdrawal guide: for one in 200 million of you
- Thesis reading_ Chinese NLP_ ELECTRA
- JVM原理简介
猜你喜欢

MC Layer Target

移动端——uniapp开发记录(公共请求request封装)

2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination

Uipath practice (08) - selector

Do you know UVs in modeling?

联发科技2023届提前批IC笔试(题目)
![[USACO 2009 Dec S]Music Notes](/img/e6/282a8820becdd24d63dcff1b81fcaf.jpg)
[USACO 2009 Dec S]Music Notes

Handling record of electric skateboard detained by traffic police

data2vec! New milestone of unified mode

【XSS绕过-防护策略】理解防护策略,更好的绕过
随机推荐
@RequestMapping
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
Thesis reading_ ICD code_ MSMN
Market status and development prospects of the global automatic tea picker industry in 2022
2022 Shandong Province safety officer C certificate examination content and Shandong Province safety officer C certificate examination questions and analysis
第十九届浙江省 I. Barbecue
Market status and development prospect prediction of global SoC Test Platform Industry in 2022
Hj35 serpentine matrix
I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional
Learning record of arouter principle
Leetcode simple question: check whether the array is sorted and rotated
Integration of Android high-frequency interview questions (including reference answers)
General undergraduate college life pit avoidance Guide
Contents of welder (primary) examination and welder (primary) examination in 2022
MPM model and ab pressure test
Keepalived热备与HAProxy
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
The least operation of leetcode simple problem makes the array increment
Symbol of array element product of leetcode simple problem