当前位置:网站首页>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
.
边栏推荐
- 【SQL注入点】注入点出现位置、判断
- LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
- Market status and development prospects of the global autonomous marine glider industry in 2022
- [set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
- AWS VPC
- Shuttle + Alluxio 加速内存Shuffle起飞
- Symbol of array element product of leetcode simple problem
- Market status and development prospects of the global IOT active infrared sensor industry in 2022
- RSRS index timing and large and small disc rotation
- Triangular rasterization
猜你喜欢
【XSS绕过-防护策略】理解防护策略,更好的绕过
逆袭大学生的职业规划
Two drawing interfaces - 1 Matlab style interface
2022 new examination questions for the main principals of hazardous chemical business units and examination skills for the main principals of hazardous chemical business units
Concurrent operation memory interaction
Php+mysql registration landing page development complete code
Library management system based on SSM
Learning practice: comprehensive application of cycle and branch structure (I)
4 years of experience to interview test development, 10 minutes to end, ask too
消息队列(MQ)介绍
随机推荐
Summary of training competition (Lao Li's collection of questions)
Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
2.14 summary
Mount NFS in kubesphere
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
Leetcode simple question: check whether the string is an array prefix
并发操作-内存交互操作
Two drawing interfaces - 1 Matlab style interface
Mobile terminal - uniapp development record (public request encapsulation)
联发科技2023届提前批IC笔试(题目)
Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
Writing skills of multi plate rotation strategy -- strategy writing learning materials
消息队列(MQ)介绍
Hire cashier (differential constraint)
Games101 Lesson 9 shading 3 Notes
Thesis reading_ ICD code_ MSMN
Employee attendance management system based on SSM
Shell script Basics - basic grammar knowledge
4 years of experience to interview test development, 10 minutes to end, ask too