标题:对宽字符串wchar_t的疑惑
只看楼主
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
 问题点数:0 回复次数:0 
对宽字符串wchar_t的疑惑
宽字符wchar_t实际使用 typedef unsigned short wchar_t; 语句进行的定义,也就是宽字符wchar_t本质上就是unsigned short 类型,但是不知道为什么,代码:
#include <iostream>
#include <STRING>
#include <TCHAR.H>
#include <WINDOWS.H>
using namespace std ;
int  const  MAX_LEN = 100 ;

int main()
{
    wchar_t  ustr[MAX_LEN] ;

    for (int i = 0 ; i < MAX_LEN -1 ; i++)
    {
        ustr[i] = 'a' ;
    }
    ustr[MAX_LEN -1] = '\0' ;

    cout << ustr<<endl ;
    cout << wcslen(ustr) << endl ;
    return 0 ;
}    能通过编译,而代码:
int main()
{
    unsigned short  ustr[MAX_LEN] ;

    for (int i = 0 ; i < MAX_LEN -1 ; i++)
    {
        ustr[i] = 'a' ;
    }
    ustr[MAX_LEN -1] = '\0' ;

    cout << ustr<<endl ;
    cout << wcslen(ustr) << endl ;
    return 0 ;
}却不能通过编译?
我使用的是  VS2005 为编译器。
搜索更多相关主题的帖子: VS2005 宽字符 wchar_t typedef 
2008-08-14 21:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-228324-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.474502 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved