strtok crash Not sure why its bugging
In the strtok it doesnt even give me and error it just crashes, below the g->db_cmd is a char*, can anyone help me out with this issue thank you for the help in advance.
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 d开发者_StackOverflow中文版el_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);
strtok
loops through the string it is tokenizing and replaces the delimiter characters with '\0'
. So, if g->db_cmd
points to a read-only string literal your strtok
call will crash.
精彩评论