This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char* newString = malloc(sizeof(char)*length+1); | |
for (i=length-1, j=0; i>=0; i--, j++) { | |
newString[j] = input[i]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Calculate a rook move */ | |
/* Variables to store rook position of row 3 and column 4 */ | |
board[4][0] = ROOK; | |
int pieceRow = 4; | |
int pieceColumn = 0; | |
/* For every row */ | |
for (i = 0;i <= 7; i++) { | |
/* And every column */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Print and ask for the row number */ | |
printf("\nRow? (0..7): "); | |
/* Get some input */ | |
if (fgets(input, sizeof(input), stdin)) { | |
/* Make sure it's a number! */ | |
if (sscanf(input, "%d", &pieceRow)) { | |
/* Make sure it's between 0 and 7! */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Set initial start positions */ | |
board[0][0] = ROOK; | |
board[0][1] = KNIGHT; | |
board[0][2] = BISHOP; | |
board[0][3] = QUEEN; | |
board[0][4] = KING; | |
board[0][5] = BISHOP; | |
board[0][6] = KNIGHT; | |
board[0][7] = ROOK; | |
board[1][0] = PAWN; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int board[8][8]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
OlderNewer