ch3-confstr

Chapter_3     version







confstr.c     LPI, p. 48


#include <stdio.h> // for printf(), NULL
#include <stddef.h> // for size_t
#include <unistd.h> // for confstr()
// unistd.h includes bits/confname.h, which defines
// _CS_PATH, _CS_GNU_LIBC_VERSION

int main()
{
char buf[100];
size_t n;

n = confstr(_CS_PATH, NULL, (size_t) 0);
confstr(_CS_PATH, buf, n);
printf("_CS_PATH: %s\n", buf);

n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0);
confstr(_CS_GNU_LIBC_VERSION, buf, n);
printf("_CS_GNU_LIBC_VERSION: %s\n", buf);

return 0;
}
/*
gcc confstr.c -o confstr
./confstr
_CS_PATH: /bin:/usr/bin
_CS_GNU_LIBC_VERSION: glibc 2.31
*/




Note:  See also confstr(3) on Linux_man-pages.









Chapter_3     version BACK_TO_TOP



Comments

Popular posts from this blog

Contents