I have an array of 16 bytes that contains the name of the executable segment.
char segname[16];
If the length of the segment name is less than 16 bytes, then the rest is filled with zero bytes. Otherwise, the null byte does not end.
I want to compare segname with various strings, for example. __text .
Can strncmp be called with a null-terminated string?
This post assumes that it is legal. This source code makes it legal. But my man page says:
The strncmp() function lexicographically compares strings with zero termination s1 and s2 .
The size passed to strncmp will be the size of segname .
I wonder what I should talk about.
c standards standard-library strncmp
Bilow Jan 01 '16 at 20:31 on 2017-01-01 20:31
source share