Implement the function void Build_A_List(Str30 dest[], Str30 source [][COLSIZE], int length, int *pCount) which will copy all strings with a string length equal to parameter length. The function should also update *pCount which will store the number of strings copied from source[][] to dest[] array. Code format TO DO #3: Implement function Build_A_List(). DO NOT use printf() in the function definition. */ void Build_A_List(Str30 dest[], Str30 source[][COLSIZE], int length, int *pCount) { // write code here } */
I need help in this question in C program.
Consider a 2D array of strings based on the following declarations/definitions:
#define ROWSIZE 4
#define COLSIZE 3
typedef char Str30[31];
Str30 Words[ROWSIZE][COLSIZE]; // 2D array of string
An example Words[ ][ ] array is shown below.
col0 | col1 | col2 | |
row0 | dOg | Neko | Cat |
row1 | Hello | gOoDbYE | WELCOME |
row2 | GREEN | CauliFlower | Blue |
row3 | Code | Programmer | SynTaX |
Implement the function void Build_A_List(Str30 dest[], Str30 source [][COLSIZE], int length, int *pCount) which will copy all strings with a string length equal to parameter length. The function should also update *pCount which will store the number of strings copied from source[][] to dest[] array.
Code format
TO DO #3: Implement function Build_A_List().
DO NOT use printf() in the function definition.
*/
void Build_A_List(Str30 dest[], Str30 source[][COLSIZE], int length, int *pCount)
{
// write code here
}
*/
Example #1: Build_A_List(dest, Words, 4, &count); // where Str30 dest[MAXSIZE * COLSIZE]
The resulting dest[] array that contains all the words with a string length of 4 copied in row major order is shown below. The value
of count = 3
Neko |
Blue |
code |
Example #2: Build_A_List(dest, Words, 88, &count);
The resulting dest[] array will not contain any word since there is no word in source[][] that has a string length of 88. The value of count = 0.
Step by step
Solved in 2 steps