A move in chess (http://en.wikipedia.or g/wiki/Algebraic_notat ion_(chess)) can be written entering three characters:
like: Ka1
The first letter can be K, Q, R, N, B, P
The second letter can be a, b, c, d, e, f, g, h,
The third letter can be 1, 2, 3, 4,, 5, 6, 7, 8
User can input 3 characters using the above rules
If something is wrong with input characters the program must show error message (for example when inputs ka1 - the first letter must be capital between K, Q, R, N, B, P)
I wrote a program but I don't know what mistakes I've done or if this can be done in a different way
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char kinisi[4];
char a1, a2;
int a3;
int main (void)
{
printf("Please give white move:");
gets(kinisi);
kinisi[0]=a1;
kinisi[1]=a2;
kinisi[3]=a3;
while (((a1 =='K') || (a1 =='Q') || (a1 =='R') || (a1 =='N') || (a1 =='B') || (a1 =='P')) && ((a2 =='a') || (a2 =='b') || (a2 =='c') || (a2 =='d') || (a2 =='e') || (a2 =='f') || (a2 =='g') || (a2 =='h')) && ((a3 <9) && (a3 >0))) {
printf("white move ok\n");
}
}
I've got Pelles compiler and the mistake that founds is:
The function 'gets' is marked as deprecated
like: Ka1
The first letter can be K, Q, R, N, B, P
The second letter can be a, b, c, d, e, f, g, h,
The third letter can be 1, 2, 3, 4,, 5, 6, 7, 8
User can input 3 characters using the above rules
If something is wrong with input characters the program must show error message (for example when inputs ka1 - the first letter must be capital between K, Q, R, N, B, P)
I wrote a program but I don't know what mistakes I've done or if this can be done in a different way
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char kinisi[4];
char a1, a2;
int a3;
int main (void)
{
printf("Please give white move:");
gets(kinisi);
kinisi[0]=a1;
kinisi[1]=a2;
kinisi[3]=a3;
while (((a1 =='K') || (a1 =='Q') || (a1 =='R') || (a1 =='N') || (a1 =='B') || (a1 =='P')) && ((a2 =='a') || (a2 =='b') || (a2 =='c') || (a2 =='d') || (a2 =='e') || (a2 =='f') || (a2 =='g') || (a2 =='h')) && ((a3 <9) && (a3 >0))) {
printf("white move ok\n");
}
}
I've got Pelles compiler and the mistake that founds is:
The function 'gets' is marked as deprecated
Comment