The CIDR Block Error of C language must have been encountered by everyone. Sort it out for learning.
Today, I executed a program. after a long time of running, the segment was incorrect. I located it and it turned out to be a problem with fprintf, specifically the problem with vfprintf.
Program received signal SIGSEGV, Segmentation fault. 0x0098735e in vfprintf () from/lib/libc. so.6
The call stack is:
#0 0x0098735e in vfprintf () from/lib/libc. so.6
#1 0x0098e3cf in fprintf () from/lib/libc. so.6
Replace fprintf with printf.
I started to think it was a length problem that caused overflow. Later I combined various solutions and found that it was not a length problem. It was originally a problem caused by a special character sequence, the culprit is the string % 20, which causes the vfprintf to run abnormally. % 20 is actually the url encoding of spaces.
The above is mainly caused by the variable parameter list and the character string formatting feature. For example, the % 20s sequence is considered to be a string, but we didn't input a string, so the program will be faulty. In general, as long as the string contains %, even if there is no segment error, there will be a very strange output phenomenon.
Similarly, because sprintf also calls vfprintf, it should also have problems.