C 如何读取帐户文件?

C 如何读取帐户文件?,c,linux,C,Linux,我打开了会计。但是我看不懂。这是密码 /* my_acct.c */ #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/acct.h> int main(int argc, char *argv[]) { char *file_acct = "acct_test.txt"; int choice= 0; if(argc >

我打开了会计。但是我看不懂。这是密码

/* my_acct.c */
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/acct.h>

int main(int argc, char *argv[])
{
    char *file_acct = "acct_test.txt";
    int choice= 0;
    if(argc > 1)
        choice = strcmp(argv[1], "ON") ? 0 : 1;

    if(choice) {
        if(acct(file_acct) != 0){     // on success: 0
                perror("acct");
        }
    } else {
        if(acct(NULL) != 0) {
                perror("acct");
        }
    }
    return 0;
}
/*我的账户c*/
#包括
#包括
#包括
#包括
int main(int argc,char*argv[])
{
char*file\u acct=“acct\u test.txt”;
int-choice=0;
如果(argc>1)
choice=strcmp(argv[1],“ON”)?0:1;
如果(选择){
如果(acct(file_acct)!=0){//成功时:0
perror(“acct”);
}
}否则{
如果(帐户(空)!=0){
perror(“acct”);
}
}
返回0;
}
当我运行我的程序时,
my\u acct ON
,进程终止会登录到给定的文件(
acct\u test.txt
)。但是我无法读取文件。它看起来是以二进制格式写入的。

如何读取
acct\u test.txt
文件?或者我必须更改代码?

您可以使用
psacct
软件包中的
dump acct
命令