getgroups

getgroups()用來取得目前用戶所屬的添加組。

基本介紹

  • 中文名:getgroups
  • 頭檔案:#include<unistd.h>
  • 相關函式:initgroups,setgroup
  • 範疇:編程
頭檔案,函式原型,說明,相關函式,範例,

頭檔案

#include<sys/types.h>

函式原型

int getgroups(int size,gid_t list[]);

說明

參數size為list[]所能容納的gid_t數目。如果參數size值為零,此函式僅會返回用戶所屬的添加組數目,如有錯誤則返回-1。
EFAULT 參數list數組地址不合法。
EINVAL 參數size值比添加組的數目少,但不是零。

相關函式

initgroups,setgroup,getgid,setgid

範例

#include <stdio.h>
#include<unistd.h>
#include<sys/types.h>
main()
{
gid_t list[500];
int x,i;
x = getgroups(0,list);
getgroups(x,list);
for(i=0;i<x;i++)
printf("%d:%d\n",i,list[i]);
}

相關詞條

熱門詞條

聯絡我們