C++ Ascii码输出?。需要解决方案吗
嘿,我想在一个文本文件中输出一些ascii字符,然后将它们加载并用于菜单。有谁能帮我做这件事吗。这是我的密码:C++ Ascii码输出?。需要解决方案吗,c++,file-io,menu,C++,File Io,Menu,嘿,我想在一个文本文件中输出一些ascii字符,然后将它们加载并用于菜单。有谁能帮我做这件事吗。这是我的密码: #include "MenuText.h" #include <iostream>//To allow the use of Header files. #include <fstream>//To allow the use of external .txt files. using namespace std; using std::cout; MenuT
#include "MenuText.h"
#include <iostream>//To allow the use of Header files.
#include <fstream>//To allow the use of external .txt files.
using namespace std;
using std::cout;
MenuText::MenuText()
{
mText = "Default";
}
MenuText :: MenuText(string text)
{
mText = text;
}
void MenuText::print()
{
cout<< "Story= " << mText<< endl;
cout<< endl;
}
void MenuText::save(ofstream& outFile)
{
outFile<< "┏┳┳┳┳┳┳┳┳●●●●●●━┓ ┣╋╋╋╋╋╋╋┫●●●●●●●┃\n"
"┣┻┻┻┻┻┻┻┻━━−●●●●┃ ┃Marooned ™ ●●●●┏┫\n "
"┣┳┳┳┳┳┳┳┳−●●●●┏╋┫ ┣╋╋╋╋╋╋╋┫●●●●−┻┻┫\n"
"┣╋╋╋╋╋╋╋┫●●●●●●●┃ ┗┻┻┻┻┻┻┻┻●●χ " << mText<< endl;
cout<< endl;
outFile<< endl;
}
void MenuText::load(ifstream& inFile)
{
string garbage;
inFile>> garbage >> mText;
}
void MenuText::Menu()
{
cout<< "\n\t******Menu******\n\n";
cout<< "Please choose one of the following:\n";
cout<< "1 -Play Game.\n";
cout<< "2 -Exit.\n";
}
void MenuText::text()
{
ifstream text;
string line;
text.open("Text.txt");
if (text.is_open())
{
while ( text.good() )
{
getline (text,line);
cout << line << endl;
}
text.close();
}
else{
throw("The text file did not load.......!!!");
}
}
#包括“MenuText.h”
#包含//以允许使用头文件。
#包含//以允许使用外部.txt文件。
使用名称空间std;
使用std::cout;
MenuText::MenuText()
{
mText=“默认”;
}
MenuText::MenuText(字符串文本)
{
多行文字=文本;
}
void MenuText::print()
{
cout首先搜索每个字符的ASCII/UNI代码,然后使用这些代码创建字符*或字符[]字符串/数组。然后,您可以根据需要使用此字符串。
e、 g
是这些代码的链接…这些不是ASCII字符。请读出ASCII是什么,然后返回这里。@KerrekSB当我第一次运行包含这些字符的程序时。t说它们是ASCII@Pendo826:它们实际上是Unicode的。@MSalters哦,好的,谢谢你的建议。
char str[5]={125,124,126,122,121};