[solved]-Write Function C Reads Words File Two Dimensional Array Characters Make Code Work Copy Wor Q39088256
Write a function in C that reads words from a file into atwo-dimensional array of characters. To make the code work, you cancopy the words into a file in http://repl.it, (Links to an externalsite.)
The word.txt file contains:
10
to
you
they
not
go
her
as
think
take
come
The first line in the file contains a count of the number ofwords in the file. Each subsequent line contains a single word.Read the first line into an int variable called “count”, and usethat variable to drive a for loop that reads in the remaining linesas words.
You will need to allocate memory for both the array and each ofits “strings” or character arrays. I suggest you start with thefollowing global declarations:
const int wordSize = 100;int count;char** words;
You will need this to allocate space for the first dimension ofthe array:
words = (char**)malloc(count * sizeof(char*));
And this (inside your for loop) to allocate space for each wordin the array:
words[i] = (char*)malloc(wordSize);
When you’ve completed the function, write some code in main thattests the function to make sure it works. I suggest printing thefirst and last word in the array.
Expert Answer
Answer to Write a function in C that reads words from a file into a two-dimensional array of characters. To make the code work, yo… . . .
OR

