在strtok它甚至没有给我和错误它只是崩溃,在g-> db_cmd下面是一个char *,任何人都可以帮我解决这个问题,谢谢你的帮助提前。
short processCMD(i_gsd_ptr g, i_exit_cb_ptr i_exit_cb, char* i_cmd )
{
/*-------------------LOCAL VARIABLES-----------------*/
struct local_stack_def
{
char delims[3];
int x;
short cmd_match, error,len_eulm,range_eulm, imp_eulm, sub_cmd_match;
short* cmd_len;
short* db_len;
char val_cmd[10];
_cc_status cc;
char DataEntry[400];
char msg_eulm[400];
char* cmd;
char* db_cmd;
char space_const[2];
char *result;
char del_const[2];
};
short pool_err;
struct local_stack_def *l;
#pragma nowarn (30)
l = POOL_GETSPACE_(i_exit_cb->Pool_addr,sizeof(struct local_stack_def),&pool_err );
#pragma warn
if (pool_err != 0)
{
exit(EXIT_FAILURE);
}
l->x = 1;
l->cmd_match=0;
*l->db_len = 0;
l->db_cmd = g->db_cmd;
l->imp_eulm= 1;
#pragma nowarn (207)
strncpy(l->del_const,"~",2);
#pragma warn
l->result = strtok( g->db_cmd,l->del_const);
strcpy(l->db_cmd,l->result);
答案 0 :(得分:3)
strtok
遍历它正在标记的字符串,并用'\0'
替换分隔符字符。因此,如果g->db_cmd
指向只读字符串文字,则strtok
调用将会崩溃。