| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1185 人关注过本帖
标题:关于wsprintf和outtextxy使用输出乱码的问题
只看楼主 加入收藏
Humiliation
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-4-15
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
关于wsprintf和outtextxy使用输出乱码的问题
程序代码:
#include<stdio.h>
#include<iostream>
#include<graphics.h>
#include<easyx.h>
#include<string.h>
#include<stdlib.h>
#include<Windows.h>

using namespace std;
int main()
{
    initgraph(640, 500);
    wchar_t str[10];
    wsprintf(str, L"%s","aa" );
    outtextxy(0,0,str);
    system("pause");
}




在VC++2010中 为什么输出出来的是乱码?
搜索更多相关主题的帖子: 输出 str namespace 乱码 include 
2021-04-15 13:33
Humiliation
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-4-15
收藏
得分:0 
是个小白,学校的实践周要求。很多内容都是网络上下来的,很多函数都没见过。。
2021-04-15 13:37
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:20 
#include<graphics.h>、initgraph(640, 500) 等~!@#$%我就不说了

wsprintf 这个MS的私有API是这么用的
程序代码:
#include <stdio.h>
#include <tchar.h>
#include <windows.h>

int main( void )
{
    {
        char str[10];
        wsprintfA( str, "%s", "aa" ); // 这是MS的,不是C++的
        puts( str );
    }
    {
        wchar_t str[10];
        wsprintfW( str, L"%s", L"aa" ); // 这是MS的,不是C++的
        _putws( str ); // 这是MS的,不是C++的
    }
    {
        TCHAR str[10]; // 这是MS的,不是C++的
        wsprintf( str, TEXT("%s"), TEXT("aa") ); // 这是MS的,不是C++的
        _putts( str ); // 这是MS的,不是C++的
    }
}


假如没有特殊的爱好,可以用C语言的标准函数,如
程序代码:
#include <stdio.h>

int main( void )
{
    {
        char str[10];
        sprintf( str, "%s", "aa" );
        puts( str );
    }
    {
        wchar_t str[10];
        swprintf( str, sizeof(str)/sizeof(*str), L"%s", L"aa" );
        fputws( str, stdout );
    }
}
2021-04-15 14:03
快速回复:关于wsprintf和outtextxy使用输出乱码的问题
数据加载中...
 
   



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

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