(Dev-c++) 将'int'分配给'char[1]'的不兼容类型
(Dev-c++) incompatible types in assignment of 'int' to 'char[1]'
我最近在尝试用c++做一个游戏,这是代码。
#include <iostream>
#include <windows.h>
using namespace std;
//cut
void WritePlayerUsername(int PlayerNumber)
{
//clear(); this is same as system("cls");
char First[1], Second[1], Third[1], Fourth[1], Fifth[1];
char Sixth[1], Seventh[1], Eighth[1], Nineth[1], Tenth[1];
cout<<"Username";
for(int a=0; a<2; a++) cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<" [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]"<<endl;
gotoxy(14, 93);
First=getch(); //Here
cout<<First;
gotoxy(14, 97);
Second=getch(); //here
cout<<Second;
gotoxy(14, 101);
Third=getch(); //here
cout<<Third;
gotoxy(14, 105);
Fourth=getch(); //here
cout<<Fourth;
gotoxy(14, 109);
Fifth=getch(); //here and something like these
cout<<Fifth;
gotoxy(14, 113);
Sixth=getch();
cout<<Sixth;
gotoxy(14, 117);
Seventh=getch();
cout<<Seventh;
gotoxy(14, 121);
Eighth=getch();
cout<<Eighth;
gotoxy(14, 125);
Nineth=getch();
cout<<Nineth;
gotoxy(14, 129);
Tenth=getch();
cout<<Tenth;
fstream file;
if(PlayerNumber==1){ file.open("C:\Game\Users\1\username.txt", ios::in | ios::out | ios::binary);
file<<First<<Second<<Third<<Fourth<<Fifth<<Sixth<<Seventh<<Eighth<<Nineth<<Tenth;}
}
我的dev -c++编译器说[错误]int对char[1]赋值时类型不兼容
我现在不太擅长c++,我还在学习,我需要一个解决方案。由于为什么使用char First[1]
?它是包含char
类型元素的单元素数组。用
char First;
相关文章:
- 枚举类的 C 样式强制转换到基础类型 char 的引用
- 无法使用类型 'const char *' 的左值初始化类型 'char *' 的成员子对象
- C++:将模板类型 char 转换为 std::string
- 获取"rw_ssid"中成员"长度"的错误请求,该成员属于非类类型"char*"
- 将"std::string {aka std::basic_string}"赋值中的不兼容类型<char>
- 成员引用基类型 'char' 不是 C++ 中的结构或联合
- 错误:请求成员 .. 是非类类型"char"
- 错误:为"运算符 std::string {aka std::__cxx11::basic_string}"指定的返回类型<char>
- 为什么类型 char 返回不同的值?
- 请求成员 'begin' in 'c' 中,它是非类类型 'char [101]' sort(c.begin(), c
- C++ 类型 "char" 的参数与类型 "const char" 的参数不兼容
- 类型 "const char *" 的参数与类型 "char *" 的参数不兼容
- 类型 "const char*" 的参数与类型 "char*" 的参数不兼容。但是为什么?:(
- 创建进程使用路径时出现错误事件:类型 "char *" 的 E0167 参数与类型 "LPWSTR" 的参数不兼容
- 类型 "const char *" 的默认参数与类型 "char *" 的参数不兼容
- 返回类型 char* 的成员函数返回在 while 循环后包含不同字符串的地址
- 接受类型char的输入的问题
- 错误:无法递增类型 'char [6]' 的值
- "char *" 类型的值不能用于初始化类型 "char" 的实体
- 类型 "char *" 的参数与类型 "LPWSTR" 的参数不兼容