Question: CODING IN C: Enhance the code to handle any # of words as parameters and output them in a fancy pattern as shown below -

CODING IN C: Enhance the code to handle any # of words as parameters and output them in a fancy pattern as shown below - use a block of 16x16 characters for each word. Note that 16*16 = 256 (decimal) = 400 (octal).

Code given for copy and paste:

#include

#include

#include

#include

#include

#include

#define LINESIZE 16

//use one command line argument

int main(int argc, char *argv[]) {

if (argc != 2) {

printf("Usage: diagonal ");

return -1;

}

//create a file so that 16 rows of empty will appear with od -c command

int fd = open("diagonal.out", O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);

char space = ' ';

for(int line=0; line

for(int column=0; column

write(fd, &space, 1);

//Each line of od outputs 16 characters

//So, to make the output diagonal, we will use 0, 17, 34, ....

int n = strlen(argv[1]);

for(int i=0; i

lseek(fd, (LINESIZE+1)*i, SEEK_SET);

write(fd, &argv[1][i], 1);

}

close(fd);

puts("diagonal.out has been created. Use od -c diagonal.out to see the contents.");

}CODING IN C: Enhance the code to handle any # of words

{ cslinux1: /linux3/a6\} make diagonal2 { cslinux1: /linux3/a6\} diagonal2 Jey Veerasamy Professor UTDallas diagonal2.out has been created. Use od -c diagonal2.out to see the contents. { cslinux1: 1 linux 3/a6} od -c diagonal2.out

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!