I had a working program that displayed a hollow rectangle from *. I wanted the the user to be able to choose what symbol the rectangle would be drawn from. My attempt killed the program.
I knew it was too easy to work. what can be don to fix this?
Code:
int main(void)
{
int inner, outer;// loop control varibles
int length, width;
int icon;// was *
printf("This program draws a hollow rectangle using a character of your choice\n\n");
printf("Choose character for display\n ");
scanf("%d", &icon);
printf("Enter length: ");
scanf("%d",&length);
printf("Enter width: ");
scanf("%d",&width);
for(inner = 0; inner < width; inner ++)// prints top row of the icon
printf("icon");// was *
printf("\n");
for(inner = 0; inner < length; inner ++)// prints both sides starting with left
{
printf("icon");//was*
for(outer = 0; outer < (width-2); outer ++)// prints spaces to where the right column should be
printf(" ");
printf("icon");// prints an icon in the right column //was*
printf("\n");
}// end for
for(inner = 0; inner < width; inner ++)// prints bottom row of icon
printf("icon");//was*
printf("\n\n");
}// end main