I have created this simple code:
For the size of an array with 2 values (
n
andm
), verify ifn
andm
are >= 1.m
= width andn
= height.
The code works but I'm sure it isn't optimized.
printf("Number of ligns.");
scanf("%d",n);
printf("Number of columns.");
scanf("%d",m);
if(*n >= 1)
{
if(*m >= 1)
{
printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
}
else
{
while(*m < 1)
{
printf("Error, number of colums/ligns < 1. \n");
scanf("%d",m);
}
printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
}
}
else
{
while(*n < 1)
{
printf("Error, number of colums/ligns < 1. \n");
scanf("%d",n);
}
if(*m >= 1)
{
printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
}
else
{
while(*m < 1)
{
printf("Error, number of colums/ligns < 1. \n");
scanf("%d",m);
}
printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
}
}