kamikaze_pilot
kamikaze_pilot

Reputation: 14834

c++ char question

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?

Upvotes: 0

Views: 227

Answers (4)

Jesse Emond
Jesse Emond

Reputation: 7480

It returns pointer to char, which is basically a c-string.

Take a look at this tutorial: http://www.cprogramming.com/tutorial/lesson9.html

Upvotes: 1

Seth Carnegie
Seth Carnegie

Reputation: 75130

Yeah, in C, a char* points to an array of characters. C treats arrays of characters as strings, terminated by a null byte.

Upvotes: 2

c-smile
c-smile

Reputation: 27460

char * is a pointer on char - address of sequence of characters.

Upvotes: 1

ultifinitus
ultifinitus

Reputation: 1893

The return is a char* or a c-style string =)

Upvotes: 1

Related Questions