| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1173 人关注过本帖
标题:对宽字符串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
快速回复:对宽字符串wchar_t的疑惑
数据加载中...
 
   



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

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