小编Joe*_*hor的帖子

如何在不使用_setmode的情况下在C ++中输出unicode

我试图在控制台输出中插入unicode值,在这种情况下为\ u250F或?。我到处搜寻,有人推荐各种各样的东西。在讨论我尝试过的内容之前,我正在使用Windows和Visual Studio 2013。

主要错误

当我尝试多个“修复程序”时(如果未指定),我总是会遇到相同的错误:

Debug Assertion Failed!
Program: ...nts\visual studio 2013\Projects\roguelike\Debug\roguelike.exe
File: f:\dd\vctools\crt\crtw32\stdio\fputc.c
Line: 48

Expression: ((_Stream->_flag & _IOSTRG) || ( fn = _fileno(_Stream), 
((_textmode_safe(fn) ==  _IOINFO_TM_ANSI && !_tm_unicode_safe(fn))))

For more information on how your program can cause an assertion failure, 
see the Visual C++ documentation on asserts

(Press Retry to debug the application)
Run Code Online (Sandbox Code Playgroud)

我尝试过的

我试图做以下所有事情来输出它:

Debug Assertion Failed!
Program: ...nts\visual studio 2013\Projects\roguelike\Debug\roguelike.exe
File: f:\dd\vctools\crt\crtw32\stdio\fputc.c
Line: 48

Expression: ((_Stream->_flag & _IOSTRG) || ( fn = _fileno(_Stream), 
((_textmode_safe(fn) == …
Run Code Online (Sandbox Code Playgroud)

c++ unicode cout visual-studio-2013

5
推荐指数
1
解决办法
3841
查看次数

使用结构和数组访问冲突而不使用指针

所以我试图让这个程序在结构数组中采用一个struct数组,并为它分配一个1-9的随机数

struct multiDim
{
    int t[16];
};
struct multi
{
    multiDim t[16];
};
multi generate()
{
    multi m;
    srand(time(NULL));
    for (int i = 0;i <= 16; i++)
    {  
        for (int I = 0;I <= 16;I++)
        {
        int ii = rand();
        ii = ii % 10;
        if (ii <= 9)
        {
            m.t[i].t[I] = ii;
        }
    }
}
return m;
Run Code Online (Sandbox Code Playgroud)

}

当我尝试使用Visual Studio 2013编译它时,当我尝试返回m时,它会导致错误,说明

ConsoleApplication2.exe中0x0002609B处的未处理异常:0xC0000005:访问冲突写入位置0x00000007.

我在结构中的数组中使用数组的原因是因为要避免<std::vector<std::vector<int>>或者使用其他方法.我没有使用任何指针或解除引用操作符,所以我不确定它是如何导致它抛出的.

但是,在运行pocketcpp的另一台计算机上,我能够成功编译并执行它,但只删除了stdafx.h文件,因为它只适用于Visual Studio实例.编译器没有正确执行的任何原因?

c++ arrays struct access-violation visual-studio-2013

0
推荐指数
1
解决办法
424
查看次数