c++字符问题
所以我正在 C++ 上实现这个国际象棋程序,并且我正在尝试集成到 winboard 协议...他们说我需要编写的函数之一应该具有以下签名:
char *MoveToText(MOVE move); // converts the move from your internal format to text like e2e2, e1g1, a7a8q.
我的问题是...文本格式类似于 e2e2...但是该函数的返回类型是 char...据我所知,char 只是一个字符...
所以他们为什么告诉我使用这个签名?
或者我错了,实际上 char 还可以存储多个字符,例如 e2e2、e1g1 等?
so I'm implementing this chess program on C++ and I'm trying to integrate to winboard protocol...one of the functions that they say I need to write to do so should have the following signature:
char *MoveToText(MOVE move); // converts the move from your internal format to text like e2e2, e1g1, a7a8q.
my question is....the text formats are something like e2e2....but the return type of that function is char...and as far as I can understand it, char is just one single character....
so how come are they telling me to use this signature?
or am I mistaken and in fact char can also store multiple characters such as e2e2, e1g1 etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,在 C 中, char* 指向字符数组。 C 将字符数组视为字符串,以空字节终止。
Yeah, in C, a char* points to an array of characters. C treats arrays of characters as strings, terminated by a null byte.
返回的是 char* 或 c 风格的字符串 =)
The return is a char* or a c-style string =)
char *
是 char 上的指针 - 字符序列的地址。char *
is a pointer on char - address of sequence of characters.它返回指向 char 的指针,它基本上是一个 C 字符串。
看一下本教程:http://www.cprogramming.com/tutorial/lesson9.html< /a>
It returns pointer to char, which is basically a c-string.
Take a look at this tutorial: http://www.cprogramming.com/tutorial/lesson9.html