C++控制台下printf函数异常报错

当执行到printf("Could not");会报错:

图片说明

但是,修改以下两个位置中的任一个,都可以解决。我不明白为什么?请指导。
一、在程序的开始位置加上一句 printf("Could not");此时这句是可以打印出来的,并且下面的printf以及__tprintf 都可以打印出来
二、将for循环注释掉。

#include "pch.h"
#include <stdio.h>
#include <windows.h>
#include <tchar.h>

int _tmain()
{
    //printf("Could not");
    struct PBRecord
    {   //  bt_addr btAddr;
        WCHAR wzName[32];
        WCHAR wzNumber[64];
    };

    PBRecord *record = new PBRecord[3];
    for (int i = 0; i < 3; i++)
    {
        ZeroMemory(record[i].wzName, 2 * sizeof(record[i].wzName));
        ZeroMemory(record[i].wzNumber, 2 * sizeof(record[i].wzNumber));
    }

    printf("Could not");
    _tprintf(TEXT("Could not open file mapping object (%d).\n"), GetLastError());
    return 0;
}

2 * sizeof(record[i].wzName)
这么写越界了,因为sizeof获取的是字节大小,而不是数组长度。

sizeof(record[i].wzName)的用法不对,sizeof获得的是不同类型数据的字节数,不能得到数组的长度。