- /sys/types.h
- #ifndef __pid_t_defined
typedef __pid_t pid_t;
# define __pid_t_defined
#endif - bits/types.h
- __STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */# #define __STD_TYPE typedef
- #define __PID_T_TYPE __S32_TYPE
- #define __S32_TYPE int
Saturday, 25 August 2018
Data type of pid_t is int
Wednesday, 1 August 2018
Strncmp usage from working
SYNOPSIS
int strncmp(const char *s1, const char *s2, size_t n);
Description
The C library function int strncmp(const char *str1, const char *str2, size_t n) compares at most the first n bytes of str1 and str2.
RETURN VALUE
The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or the first n bytes thereof) is found, respectively, to be less than, to
match, or be greater than s2.
- strncmp will be usefully only if the both strings are not null terminated, at that time only it will be useful to stop the comparison upto n.
- if we are using strlen to calculate lenght to give on n, then strncmp is not useful.
- strncmp with strlen is as good as strcmp.
- Right way to use strncmp is to check for max allowed lenght. we can use max size macro used to declare the string.
Subscribe to:
Posts (Atom)