"ChessMoves.h"라는 헤더 파일과 다양한 함수가 포함 된 ChessMoves라는 파일이 있습니다. 내가헤더 파일에서 함수를 호출하는 데 도움이 필요합니다.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ChessMoves.h"
void parseNotationString(char *str, Move *whiteMove, Move *blackMove){
int i, space = 0, j = 0, k = 0, l = 0;
int white[10], black[10], move[10], to[2];
whiteMove.color = WHITE;
if(white[0] > 64)
whiteMove.piece = white[0];
if(white[0] < 64)
whiteMove.from_loc.row = white[0];
for(i = 0; i < 10; i++)
if(white[i] == 'x')
whiteMove.isCapture = 1;
for(i = 0; j < 10; i++)
if(white[i] == ' ')
to[0] = white[i-2];
to[1] = white[i-1];
printf("%c %c", to[0], to[0]);
}
에 전화 드렸습니다
헤더 파일
#ifndef __CHESSMOVES_H
#define __CHESSMOVES_H
typedef struct Location
{
// the square's column ('a' through 'h')
char col;
// the square's row (1 through 8)
int row;
} Location;
typedef struct Move
{
// location where this piece is moving from
Location from_loc;
// location where this piece is moving to
Location to_loc;
// what type of chess piece is being moved
char piece;
// whether this move captures another piece
short int isCapture;
// the color of the piece being moved
Color color;
} Move;
파일 우리는 코드를 테스트 할 파일을 받았다 해당 파일에서 그는이 있습니다
whiteMove.color != WHITE
과 whiteMove.color가 WHITE와 같지 않으면 "FAIL"이라고 표시되어 시도했습니다. 설정
whiteMove.color = WHITE
하지만 구조체 또는 공용체가 아닌 "구성원의 색상 요청"이 계속 나타납니다. 같은 것을 내가 호출하려고하는 다른 구조체에 대해 간다. 시도해 보았습니다.
Move.color = WHITE
그리고 작동하지 않습니다.
왜 초기화되지 않은'white [0]'을 테스트하고 있습니까? – Sergio
세미콜론이없는 경우 C의 구문은 없습니다. – bmargulies
whiteMove.color = 흰색; 해야합니다 whiteMove-> color; 그것은 포인터입니다. – bmargulies