Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming language help. I have attached the demo program(which uses dynamic memory allocation). The demo program stares an array of integers, but I need

C programming language help. I have attached the "demo program"(which uses dynamic memory allocation). The demo program stares an array of integers, but I need to make an array of characters. Please help me write the code and please separate the header files(.h) and source files(.c). Also, please comment the code if necessary. Thank you

In this homework assignment, you will write a program to solve a word search puzzle. An example puzzle is shown below, along with the search words. The goal of the puzzle is to find each search word. The trick is that the search words are surrounded by random characters. Further, the search words can appear forwards, backwards, horizontally, vertically, or diagonally (in either direction)!

image text in transcribed

This program will read a puzzle from a text file saved to disk. The first line of the file should contain the dimensions of the grid (rows, then columns). On subsequent lines, the actual grid of characters should be provided. The input may contain upper and lower case characters, but you should convert them all to lower case when you read them.

"Demo Program(dynamic mememory 2D array) that uses dynamic memory allocation."

#include  // Allows printf, ... #include  #include  // Allows malloc, ... #include  // Allows errno int** createArray(int rows, int cols); void fillArray(int** myArray, int rows, int cols); void printArray(int** myArray, int rows, int cols); void deleteArray(int** myArray, int rows, int cols); int main(void) { const int ROWS = 4; const int COLS = 8; int** myArray; myArray = createArray(ROWS, COLS); fillArray(myArray, ROWS, COLS); printArray(myArray, ROWS, COLS); deleteArray(myArray, ROWS, COLS); return EXIT_SUCCESS; } int** createArray(int rows, int cols) { int **myArray; // Allocate a 1xROWS array to hold pointers to more arrays myArray = calloc(rows, sizeof(int *)); if (myArray == NULL) { printf("FATAL ERROR: out of memory: %s ", strerror(errno)); exit(EXIT_FAILURE); } // Allocate each row in that column for (int i = 0; i  

EWDISHWASHERZTLARDERBY ARKEVREFRIDGERATORYKTN EWDISHWASHERZTLARDERBY ARKEVREFRIDGERATORYKTN

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

121. If X is uniformly distributed on [1, 3], find the pdf of Y X2.

Answered: 1 week ago