#include stdio.h
#include stdlib.h
#include stdbool.h
void hollow_sqr(size_t height, size_t width, char c);
void solid_sqr(size_t height, size_t width, char c);
int main()
{
size_t height, width;
char c, buffer[5],type, *ptr;
void (*sqr_ptr)(size_t height, size_t width, char c);
puts("enter the height and width of the square");
fgets(buffer, 5, stdin);
height = strtoul(buffer, &ptr, 10);
if(!*ptr && (ptr != buffer))
{
fgets(buffer, 5, stdin);
width = strtoul(buffer, &ptr, 10);
}
else
{
puts("parse error");
return 1;
}
if(!*ptr && (ptr != buffer))
{
puts("hollow or solid?(0 or 1)");
type = getchar();
}
else
{
puts("parse error");
return 1;
}
puts("what symbol do you want to use?");
c = getchar();
if(!height || !width)
{
puts("\nsize cannot be zero!");
main();
}
else
{
sqr_ptr = (!type) ? hollow_sqr : solid_sqr;
sqr_ptr(height, width, c);
}
getchar();
return 0;
}
void hollow_sqr(size_t height, size_t width, char c)
{
short i,j;
bool endrow;
for(i=0;i