IrmaMoves.h : #include \"IrmaMoves.h\" typedef struct Move { Irma irma; // an in
ID: 3752666 • Letter: I
Question
IrmaMoves.h :
#include "IrmaMoves.h"
typedef struct Move {
Irma irma; // an instance of Irma
L Location from_loc; // location where Irma is moving from
Location current_loc; // location where Irma is passing over
Location to_loc; // location where Irma is moving to
} Move;
typedef struct Location {
char col; // the square's column ('a' through 'h')
int row; // the square's row (0 through 7)
} Location;
typedef struct Irma {
int ws; // wind speed (MPH)
int wg; // wind gusts (MPH)
} Irma;
IrmaMoves.c:
#include
#include
#include
#include "IrmaMoves.h"
char **createMapBoard(void){
char **board = malloc(8*sizeof(char *)); //dynamically allocate memory for rows
for(int i = 0 ; i < 8 ; i++) //dynamically allocate memory for indiviual elements
board[i] = malloc( 8*sizeof(char) );
board[0][0] = 'F'; //initialize the array with the map layout
board[0][1] = 'F';
board[0][2] = ' ';
board[0][3] = ' ';
board[0][4] = ' ';
board[0][5] = ' ';
board[0][6] = ' ';
board[0][7] = ' ';
board[1][0] = ' ';
board[1][1] = 'F';
board[1][2] = ' ';
board[1][3] = ' ';
board[1][4] = ' ';
board[1][5] = ' ';
board[1][6] = ' ';
board[1][7] = ' ';
board[2][0] = ' ';
board[2][1] = 'F';
board[2][2] = 'F';
board[2][3] = ' ';
board[2][4] = ' ';
board[2][5] = ' ';
board[2][6] = ' ';
board[2][7] = ' ';
board[3][0] = ' ';
board[3][1] = ' ';
board[3][2] = 'F';
board[3][3] = ' ';
board[3][4] = ' ';
board[3][5] = ' ';
board[3][6] = ' ';
board[3][7] = ' ';
board[4][0] = ' ';
board[4][1] = ' ';
board[4][2] = 'K';
board[4][3] = ' ';
board[4][4] = ' ';
board[4][5] = ' ';
board[4][6] = ' ';
board[4][7] = ' ';
board[5][0] = 'C';
board[5][1] = ' ';
board[5][2] = ' ';
board[5][3] = 'B';
board[5][4] = ' ';
board[5][5] = ' ';
board[5][6] = ' ';
board[5][7] = ' ';
board[6][0] = ' ';
board[6][1] = 'C';
board[6][2] = 'C';
board[6][3] = ' ';
board[6][4] = 'D';
board[6][5] = ' ';
board[6][6] = ' ';
board[6][7] = ' ';
board[7][0] = ' ';
board[7][1] = ' ';
board[7][2] = 'C';
board[7][3] = ' ';
board[7][4] = ' ';
board[7][5] = 'D';
board[7][6] = 'D';
board[7][7] = ' ';
return board;
};
char **destroyMapBoard(char **board){
//frees up the memory allocated to the board
free(board);
return NULL;
};
void printMapBoard(char **board){
//printing the map in the specified format
printf("======== ");
for (int i = 0; i < 8; i++){
for (int j = 0; j < 8; j++){
printf("%c",board[i][j]);}
printf(" ");}
printf("========");
printf(" ");
printf(" ");
};
Please help with this Function everytime I ask a question the answers simply restate the Information provided above without helping with the question below:
double difficultyRating(void);
Output: This function should not print anything to the screen.
Return Value: A double indicating how difficult you found this assignment on a scale of 1.0 (ridiculously easy) through 5.0 (insanely difficult).
double hoursSpent(void);
Output: This function should not print anything to the screen.
Return Value: An estimate (greater than zero) of the number of hours you spent on this assignment.
Note: Unsure what you meant by Image not coming. I have no Images; however, I realized it was selected for the wrong subject area, so if that was the reasoning it has now been switched
Explanation / Answer
Answer:
void printMapBoard(char **board){
//printing the map in the specified format
printf("======== ");
for (int i = 0; i < 8; i++){
for (int j = 0; j < 8; j++){
printf("%c",board[i][j]);}
printf(" ");}
printf("========");
printf(" ");
printf(" ");
};
} Move;
typedef struct Location {
char col; // the square's column ('a' through 'h')
int row; // the square's row (0 through 7)
} Location;
typedef struct Irma {
int ws; // wind speed (MPH)
int wg; // wind gusts (MPH)
} Irma;
IrmaMoves.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "IrmaMoves.h"
char *board = malloc(8*sizeof(char )); //dynamically allocate memory for rows
for(int i = 0 ; i < 8 ; i++) //dynamically allocate memory for indiviual elements
board[i] = malloc( 8*sizeof(char) );
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.