顺便帮我找一下资料
http://www.csdn.net/expert/topic/905/905256.xml?temp=.150448

解决方案 »

  1.   

    代码这样写吧:
    char *p = new char[1024]; 
    p = "this is a test";
    p+=4; //此时p指向的是" is a test"串内容,注意前面的空格
          //p[-1]此时指向的是this串的's'
      

  2.   

    你通过下面的完整的代码试一下就知道了:
    #include <iostream.h>
    int main(int argc, char* argv[])
    {
    char *p = new char[1024];
    p = "this is a test";
    p+=4; 
    cout<<p[-1]<<endl;
    return 0;
    }
      

  3.   

    这也需要高手吗?
    应该这样问:
    char *p = new [1024]; 
    你知道 p[-1]是什么意思吗?
      

  4.   

    我认为-1 应该是0xffffffff,结果应该是访问越界
      

  5.   

    p[-1]==*(--p);
    char *p=new char[1024];//这样才对
      

  6.   

    很感谢各位的答复:
    都有分,问题正确的提法是:
    void main()
    {
        char *p=new char[1024];
        p += 50;
        char c = p[-1];
    }
    有几个回答是对的, 自己对应一下!正确答案是
       char c = p[-1];
    等同于
       char c = *(p-1);
      

  7.   

    在C和C++中对数组元素进行操作和对指针的操作是一样的(编译器就是这样实现的)。所以char c = p[-1]和char c = *(p-1)是一样的。