20191119在控制台上输出字符串时,只能使用cout,使用printf会出错

#include <Windows.h>
#include <stdio.h>
#include <string>
#include <iostream>
//#pragma execution_character_set("gbk")
using namespace std;

int main() {
	///0 1 2 3 4 5 6 7 8 9
	//零 壹 贰 叁 肆 五 六 柒 捌 玖
	//char temp[2];
	int iNum = 0;
	string Number[20] = { "零","壹","贰", "叁", "肆", "伍", "陆 ", "柒", "捌 ", "玖" };
	printf("请输入数字[0-9]\n");
	while (!scanf_s("%d", &iNum)) {
		printf("输入的数据类型不对\n");
		fflush(stdin);
	}
	if (iNum >= 0 && iNum <= 9) {	
		//Number[iNum].copy(temp, 2);
		//printf("输入的数值转换为中文是:%s\n",temp);
		cout<< "输入的数值转换为中文是:" << Number[iNum] << endl;
		//字符串在控制台上输出时,不能使用printf,只能使用cout20191119
	}
	else {
		printf("输入的数值不在要求范围之内\n");
	}

	system("pause");
	return 0;
}
发布了51 篇原创文章 · 获赞 0 · 访问量 570

猜你喜欢

转载自blog.csdn.net/weixin_40071289/article/details/103145886