Hello I am having some trouble using this variable in my program:
typedef char chessPos[2];
How exactly should I be scanning into it, using it in functions, and how would I properly make and use an array of this type?
to scan it i tried using:
scanf("%c%c", currPos[0], currPos[1]);
But I get this warning:
scanf: format string %c requires an argument of type 'char*', but variadic argument 1/2 has type 'int'
thank you for your help!
This is one way:
This is another way:
Your original code didn't work, because the
%cformat specifier expects achar*, i.e. a pointer to achar, andcurrPos[1]is the value. We need its address instead, e.g.currPos + 1or, equivalently,&currPos[1].