strange strtok behaviour

后端 未结 2 584
别那么骄傲
别那么骄傲 2021-01-23 07:43
char line[255];
char *token = NULL;
char *line2 = NULL;
char *temporaryToken = NULL;

if( scanf(\" %[^\\n]\", line) > 0)
    token = strtok( line, \";\" ); //divide t         


        
2条回答
  •  青春惊慌失措
    2021-01-23 08:25

    strtok modifies the original string. If you want to mix calls like that, you either need to make a copy or use strtok_r.

提交回复
热议问题