Form a box using words

I need to write a C program that prints a rectangle to the screen with a blank space in the four corners. All I can do is a rough idea of how the program will look like with only the top and left part of the rectangle, but I have no idea how to print the words the second time at the correct location..



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>

int main (void)
{

   char length[70];
   char width[70];
   int i, j;

   for (i = 0; i < 70; i++) {
      length[i] = i;

         printf("Enter word to use for length: ");
         scanf("%s", length);
         printf("%c", length[i]);

}

   for (j = 0; j < 70; j++) {
      width[j] = j;

         printf("Enter word to use for width: ");
         scanf("%s", width);
         printf("%c\n", width[j]);
}
return 0;
}




The output of the program should look like this:
Enter word to use for length: length
Enter word to use for width: width
length
w w
i i
d d
t t
h h
length
EDIT: there should be spaces in between the two vertical "width"s to form a rectangle
Last edited on
Topic archived. No new replies allowed.