当前位置:网站首页>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.
边栏推荐
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
- Network security textual research recommendation
- [PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
- JVM原理简介
- General undergraduate college life pit avoidance Guide
- Number of 1 in binary (simple difficulty)
- Market status and development prospect prediction of global fermented plant protein industry in 2022
- Preparation for school and professional cognition
- [XSS bypass - protection strategy] understand the protection strategy and better bypass
- Market status and development prospect prediction of the global fire hose industry in 2022
猜你喜欢

逆袭大学生的职业规划

Golang -- realize file transfer

Keepalived热备与HAProxy

Thesis reading_ Tsinghua Ernie

Handling record of electric skateboard detained by traffic police

Function introduction of member points mall system

Career planning of counter attacking College Students

Preparation for school and professional cognition

After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me

并发操作-内存交互操作
随机推荐
2.14 summary
第十九届浙江省 I. Barbecue
Thesis reading_ Chinese medical model_ eHealth
逆袭大学生的职业规划
Shell script -- condition judgment
Market status and development prospect forecast of global button dropper industry in 2022
Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me
The reason why the entity class in the database is changed into hump naming
Handling record of electric skateboard detained by traffic police
论文阅读_清华ERNIE
【XSS绕过-防护策略】理解防护策略,更好的绕过
Learning record of arouter principle
Pyqt control part (II)
Thesis reading_ ICD code_ MSMN
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
MediaTek 2023 IC written examination approved in advance (topic)
2022 Shandong Province safety officer C certificate examination content and Shandong Province safety officer C certificate examination questions and analysis
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)