yazoox
V2EX  ›  C++

编译错误"string too big, trailing characters truncated"怎么处理?

  •  
  •   yazoox · Apr 12, 2020 · 3227 views
    This topic created in 2247 days ago, the information mentioned may be changed or developed.

    如题,楼主 leetcode 上做题,有一道做错了。根据提示,下载了测试用例,这是一个长度为 18455 (对,你没看错)的字符串。

    于是 ,下载了测试文件。把这个测试字符串拷贝 到 VS 里面,

    string s = "拷贝下载文件中的字符串";
    
    调用 我写的函数
    

    结果,报错提示

    Error	C2026	string too big, trailing characters truncated
    

    所以,问题来了,我想在 vs 里面调试时,使用这个测试用例,怎么办呢?

    p.s. Visual Studio 2019 community version C++

    3 replies    2020-04-12 17:27:00 +08:00
    BiteTheDust
        1
    BiteTheDust  
       Apr 12, 2020
    文件读入
    yazoox
        2
    yazoox  
    OP
       Apr 12, 2020
    @BiteTheDust 好吧。确实,用文件读入到 string 里面,就可以了。谢谢!
    codehz
        3
    codehz  
       Apr 12, 2020 via Android
    我记得 vs 的字符串字面量限制是 65535 (宽字符 32767 )来着
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   853 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:40 · PVG 04:40 · LAX 13:40 · JFK 16:40
    ♥ Do have faith in what you're doing.