visualc中的strtok问题&x2B+; 我尝试了Visual C++中的Strutk,但似乎不起作用。这不是我第一次使用strtok,但我就是不知道它有什么问题。代码非常简单

visualc中的strtok问题&x2B+; 我尝试了Visual C++中的Strutk,但似乎不起作用。这不是我第一次使用strtok,但我就是不知道它有什么问题。代码非常简单,c++,visual-c++,C++,Visual C++,大体上 cout<<getLevels("/'Group'/'Channel1'")<<endl; 有误: Unhandled exception at 0x10273de8 (msvcr100d.dll) in tdmsTest.exe: 0xC0000005: Access violation writing location 0x0041c840. 光标指向strtoku.ini中的这一行 for ( ; *str != 0 ; str++ ) {

大体上

 cout<<getLevels("/'Group'/'Channel1'")<<endl;
有误:

Unhandled exception at 0x10273de8 (msvcr100d.dll) in tdmsTest.exe: 0xC0000005: Access violation writing location 0x0041c840.
光标指向strtoku.ini中的这一行

 for ( ; *str != 0 ; str++ )
    {
        if (map[*str >> 3] & (1 << (*str & 7)))
        {
            *str++ = 0; // pointing here
            break;
        }
    }
(;*str!=0;str++)的

{

if(map[*str>>3]&(1strtok()
函数将修改它的参数。您在一个字符串文本上调用它,该文本通常位于只读存储器中。

strtok试图通过插入空值代替标记来拆分字符串。我猜文本“/'Group'/'Channel1'”存储为常量,无法修改


请尝试从编译器选项中删除“启用字符串池(/GF)”标志。

问题是您正在使用笔划。停止这样做!!!笔划对大脑有害。使用。

谢谢。您是对的。在我更改为char*temp=strdup(“/”组“/”通道1“)后,无法使用
Unhandled exception at 0x10273de8 (msvcr100d.dll) in tdmsTest.exe: 0xC0000005: Access violation writing location 0x0041c840.
 for ( ; *str != 0 ; str++ )
    {
        if (map[*str >> 3] & (1 << (*str & 7)))
        {
            *str++ = 0; // pointing here
            break;
        }
    }