You should provide a compiling code. I'll assume that n
and m
are int
, but you should have added their declaration.
You should use explicit names for variables.
n
is a line count, so call itline_count
.m
iscolumn_count
.You should check the return values of
scanf
to be sure you handle gracefully EOF and bad input.You print "Error, number of colums/ligns < 1. \n" every time, so the user doesn'tcan't know if it's the lines or the columns or both that are < 1.
The english word is "lines", not "ligns".
Your checks are too complicated and redundants. The entire if/else block can be replaced by this:
while(*line_count < 1) { printf("Error, number of lines < 1. \n"); scanf("%d", line_count); } while(*column_count < 1) { printf("Error, number of colums < 1. \n"); scanf("%d", column_count); } printf("Number of lines : %x, Number of columns : %x \n", *line_count, *column_count);