I cannot change the function on itself :  Here's what I wrote for now  char ** populate(char ** words, FILE *fptr, int *currentsize, int *maxsize);     char** words;     FILE *fptr;     int *currentsize;     int *maxsize;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I cannot change the function on itself : 

Here's what I wrote for now 

char ** populate(char ** words, FILE *fptr, int *currentsize, int *maxsize);

    char** words;
    FILE *fptr;
    int *currentsize;
    int *maxsize;

char ** populate (char ** words, FILE *fptr, int *currentsize, int *maxsize) ;
The populate function will assign actual values to the dynamic array. It will fill it with strings from the
provided text files. The function will return the populated 2D dynamic string array. The functions takes 4
arguments:
A double pointer of type char called words. This is a 2D dynamic array that contains words
(strings) from the respective category (noun, verb, adjective, preposition).
2. A file pointer that contains the location of the text file from being read. The file should be
1.
open in the main function.
3. A pointer of type int called currentsize. This pointer holds the address of an integer that
keeps track of the amount of strings stored in the 2D dynamic array.
Transcribed Image Text:char ** populate (char ** words, FILE *fptr, int *currentsize, int *maxsize) ; The populate function will assign actual values to the dynamic array. It will fill it with strings from the provided text files. The function will return the populated 2D dynamic string array. The functions takes 4 arguments: A double pointer of type char called words. This is a 2D dynamic array that contains words (strings) from the respective category (noun, verb, adjective, preposition). 2. A file pointer that contains the location of the text file from being read. The file should be 1. open in the main function. 3. A pointer of type int called currentsize. This pointer holds the address of an integer that keeps track of the amount of strings stored in the 2D dynamic array.
4. A pointer of type int called maxsize. This pointer holds the address of an integer that keeps
track of the maximum amount of strings the 2D dynamic array can store.
There are some things you need to consider for this function implementation.
When allocating heap space for the string, make sure it was successful. Remember malloc
doesn't always return an address. Perform the necessary action recommended if that is the
case. It is good practice to prevent segmentation faults.
When the program starts running, the 2D dynamic array starts with 5 strings it can hold
potentially. However, you will notice that the provided text files has more than 5 strings to
read. That means we will need to allocate more heap space some how. Think about how
doubleIt will work in this scenario. That is part of the challenge in this assignment.
Transcribed Image Text:4. A pointer of type int called maxsize. This pointer holds the address of an integer that keeps track of the maximum amount of strings the 2D dynamic array can store. There are some things you need to consider for this function implementation. When allocating heap space for the string, make sure it was successful. Remember malloc doesn't always return an address. Perform the necessary action recommended if that is the case. It is good practice to prevent segmentation faults. When the program starts running, the 2D dynamic array starts with 5 strings it can hold potentially. However, you will notice that the provided text files has more than 5 strings to read. That means we will need to allocate more heap space some how. Think about how doubleIt will work in this scenario. That is part of the challenge in this assignment.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY