当前位置:网站首页>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.
边栏推荐
- 2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical
- MPM model and ab pressure test
- Factor stock selection scoring model
- 论文阅读_中文NLP_ELECTRA
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
- After job hopping at the end of the year, I interviewed more than 30 companies in two weeks and finally landed
- 第十九届浙江省 I. Barbecue
- Thesis reading_ Chinese NLP_ ELECTRA
- MediaTek 2023 IC written examination approved in advance (topic)
猜你喜欢

Arthas watch grabs a field / attribute of the input parameter

On typescript and grammar

After job hopping at the end of the year, I interviewed more than 30 companies in two weeks and finally landed

Career planning of counter attacking College Students

Learn to use the idea breakpoint debugging tool

Games101 Lesson 9 shading 3 Notes

Truncated sentences of leetcode simple questions
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

Number of uniform strings of leetcode simple problem

Thesis reading_ Chinese NLP_ ELECTRA
随机推荐
Network security textual research recommendation
[XSS bypass - protection strategy] understand the protection strategy and better bypass
Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
Do you know UVs in modeling?
Day 51 - tree problem
What functions need to be set after the mall system is built
MC Layer Target
MPM model and ab pressure test
【SQL注入点】注入点出现位置、判断
Valentine's day limited withdrawal guide: for one in 200 million of you
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
Keepalived热备与HAProxy
Review the old and know the new: Notes on Data Science
Golang -- realize file transfer
Shell script Basics - basic grammar knowledge
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me
Leetcode simple question: check whether the string is an array prefix
Market status and development prospects of the global IOT active infrared sensor industry in 2022
@RequestMapping
How to choose cross-border e-commerce multi merchant system