当前位置:网站首页>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 a special equipment related management (elevator) analysis and a special equipment related management (elevator) simulation test
- The least operation of leetcode simple problem makes the array increment
- Employee attendance management system based on SSM
- Introduction to JVM principle
- Internationalization and localization, dark mode and dark mode in compose
- Apache MPM model and ab stress test
- [PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
- 2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
- First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
- Integration of Android high-frequency interview questions (including reference answers)
猜你喜欢

C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement

Auman Galaxy new year of the tiger appreciation meeting was held in Beijing - won the double certification of "intelligent safety" and "efficient performance" of China Automotive Research Institute

Use Sqlalchemy module to obtain the table name and field name of the existing table in the database

Golang -- realize file transfer

【XSS绕过-防护策略】理解防护策略,更好的绕过

联发科技2023届提前批IC笔试(题目)

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

Introduction to JVM principle

I stepped on a foundation pit today

The simple problem of leetcode: dismantling bombs
随机推荐
Crazy scientist
Reptile exercise 03
[BMZCTF-pwn] 20-secret_ file
[SQL injection] joint query (the simplest injection method)
The 19th Zhejiang I. barbecue
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
Leetcode simple question: check whether the array is sorted and rotated
Market status and development prospect prediction of global fermented plant protein industry in 2022
消息队列(MQ)介绍
【XSS绕过-防护策略】理解防护策略,更好的绕过
Market status and development prospect prediction of global neutral silicone sealant industry in 2022
Market status and development prospect forecast of global button dropper industry in 2022
Analysis of proxy usage of ES6 new feature
Number of uniform strings of leetcode simple problem
Why does I start with =1? How does this code work?
Thesis reading_ Chinese medical model_ eHealth
Reptile exercise 02
论文阅读_中文医疗模型_ eHealth
"Niuke brush Verilog" part II Verilog advanced challenge
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me