I'm new here and it seems like this is exactly the place I need for help. I have this assignment having to do with the infamous "hollow rectangle". I've searched this forum and read my text book and the part I'm having trouble with is too specific to be mentioned anywhere.
My problem is not getting the hollow part, what I need to do is be able for the user to enter the "thickness" of the border. I just can't wrap my head around how to do it. I know it needs to be within the for-loops I have (at least I'm pretty sure it does) .
Here's what I wrote so far:
Code:
#include <stdio.h>
int main(void)
{
int i, j, height, width, border;
printf("Enter the width: ");
scanf("%d",&width);
printf("Enter the height: ");
scanf("%d", &height);
printf("Enter border thickness: ");
scanf("%d", &border);
for(i = 0; i < width; i++)
printf("*");
printf("\n");
for(i = 0; i < (height-2); i++)
{
printf("*");
for(j = 0; j < (width-2); j++)
printf(" ");
printf("*");
printf("\n");
}
for(i = 0; i < width; i++)
printf("*");
printf("\n");
system("PAUSE");
return 0;
}
So to be clear, what I have now gives me a border size of 1, and whatever the user specifies as the width and height. I need to be able to choose the border thickness, for example if I chose a thickness of 2, a width of 6, and a height of 6, it would look like this:
******
******
**00**
**00** (zeros = blank space)
******
******
I don't expect someone to write it out of course because I would much rather learn, but any help at all would greatly be appreciated
Thanks!