• 请不要在回答技术问题时复制粘贴 AI 生成的内容
feijilei
V2EX  ›  程序员

这段c++ 代码为什么会报错?

  •  
  •   feijilei · Jun 5, 2013 · 3032 views
    This topic created in 4816 days ago, the information mentioned may be changed or developed.
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {

    #define NEW_APP_PATH "C:\\QQ\\QQ.exe"
    #define VAL_OPEN NEW_APP_PATH.substr(0,NEW_APP_PATH.find_last_of('\\'));
    cout<<VAL_OPEN;
    getchar();
    return 0;
    }
    4 replies    1970-01-01 08:00:00 +08:00
    fangzhzh
        1
    fangzhzh  
       Jun 5, 2013
    char* 这种原始类型, 是没有subsr这种函数的
    楼主应该看看stl的string和char*的区别
    lichao
        2
    lichao  
       Jun 5, 2013
    有这么问问题的吗,报错你看错误提示啊
    vietor
        3
    vietor  
       Jun 5, 2013
    这从什么语言转过来的?还是从基础开始看吧,有别的语言经验,应该很快。直接拿别的语言的习惯写C++不靠谱。
    Ricepig
        4
    Ricepig  
       Jun 5, 2013
    把"C:\\QQ\\QQ.exe"看作char[] 类型,再想想,呵呵
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1262 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:39 · PVG 01:39 · LAX 10:39 · JFK 13:39
    ♥ Do have faith in what you're doing.