Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite using pointer operations. #include <stdio.h> #pragma warning(disable : 4

ID: 3563424 • Letter: R

Question

Rewrite using pointer operations.

#include <stdio.h>

#pragma warning(disable : 4996)

#define NUM_OF_CHUNKS 4
#define CHUNK_LENGTH 16

#define ENCRYPTION_SHIFT 5

char chunks[NUM_OF_CHUNKS][CHUNK_LENGTH];

void decompartmentalize(char value[(NUM_OF_CHUNKS * CHUNK_LENGTH) - (NUM_OF_CHUNKS * 2)])
{
   //TODO: Rewrite decompartmentialize(char *value) using
   //      pointer operations. It must retain the row number
   //      at the beginning of each chunk and each chuck
   //      must end with a null terminator.

   int index = 0;
   int row, col;

   for (row = 0; row < NUM_OF_CHUNKS; row++)
   {
       // insert an index for each chunk. Use for sorting
       chunks[row][0] = (char)(row + 49);

       for (col = 1; col < CHUNK_LENGTH - 1; col++)
       {
           if (index < (NUM_OF_CHUNKS * CHUNK_LENGTH) - (NUM_OF_CHUNKS * 2))
               chunks[row][col] = value[index++];
       }

       // each chunk will end with a null terminator
       chunks[row][CHUNK_LENGTH - 1] = '';
   }
}

Thanks, will check ans and vote best if correct.

Explanation / Answer

#include<stdio.h>
#pragma warning(disable : 4996)

#define NUM_OF_CHUNKS 4
#define CHUNK_LENGTH 16

#define ENCRYPTION_SHIFT 5

char chunks[NUM_OF_CHUNKS][CHUNK_LENGTH];

void decompartmentalize(char *value)
{
int index = 0;
int row, col;

for (row = 0; row < NUM_OF_CHUNKS; row++)
{
// insert an index for each chunk. Use for sorting
chunks[row][0] = (char)(row + 49);

for (col = 1; col < CHUNK_LENGTH - 1; col++)
{
if (index < (NUM_OF_CHUNKS * CHUNK_LENGTH) - (NUM_OF_CHUNKS * 2))
chunks[row][col] = *(value+index++);
}

// each chunk will end with a null terminator
chunks[row][CHUNK_LENGTH - 1] = '';
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote