strtok program crashing

前端 未结 4 1976
旧时难觅i
旧时难觅i 2020-12-19 23:15

the program for strtok given on http://www.opengroup.org/onlinepubs/000095399/functions/strtok.html crashes everytime..

#include 
...
char *t         


        
4条回答
  •  死守一世寂寞
    2020-12-19 23:56

    strtok modifies the input string line.

    char *line = "LINE TO BE SEPARATED";
    

    In this case line points to the read-only memory. Hence, cannot be modified. You need to pass char array for strtok.

提交回复
热议问题