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

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

  •  
  •   feijilei · Jun 5, 2013 · 3158 views
    This topic created in 4904 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
    fangzhzh
    Jun 5, 2013
    1
    char* 这种原始类型, 是没有subsr这种函数的
    楼主应该看看stl的string和char*的区别
    lichao
    lichao
    Jun 5, 2013
    2
    有这么问问题的吗,报错你看错误提示啊
    vietor
    vietor
    Jun 5, 2013
    3
    这从什么语言转过来的?还是从基础开始看吧,有别的语言经验,应该很快。直接拿别的语言的习惯写C++不靠谱。
    Ricepig
    Ricepig
    Jun 5, 2013
    4
    把"C:\\QQ\\QQ.exe"看作char[] 类型,再想想,呵呵
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4438 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 03:18 · PVG 11:18 · LAX 19:18 · JFK 22:18
    ♥ Do have faith in what you're doing.