1、如下结构体
struct cli_arg
{
int help;
int version;
int key_len;
int create;
int delete;
int mount;
char *passwd;
char *new_passwd;
char *backup_code;
char *cipher;
char *src;
char *dst;
int program_opcode;
char *program_name;
};
其中char*指针,在使用结构体中的变量,进行赋值是,需要分配空间,如下:
struct cli_arg carg;
carg.program_name = (char*)malloc(1024);
memset(carg.program_name, 0, 1024);
memcpy(carg.program_name, vim_opt, strlen(vim_opt));
才可正常使用。最后要记得释放内存!!!