The point of this program is to ensure valid input of two integers between 0 to 2 with a space in between (and strictly nothing else), and then to assign the result of these two integers to variables. For some reason this isn't allowed.
Very basic typecasting has me confused. The print statement %i and %i
never runs! I can't see why, even though I've put braces around the part that has "success" labelled. I've tried quite a few things.
#include <stdio.h>
#include <string.h>
int main(void)
{
int row, column;
char buffer[100];
}
printf("enter 2 values of row | column format \n");
fgets(buffer,100,stdin);
sscanf(buffer,"%c %c",&row, &column);
printf("%i %i", row,column);
// only accepts integers between 0 and 2 inclusive
if ((((int)row >=48) && ((int)row <= 50 )) && ((int)column >= 48) && ((int)column <= 50))
{
printf("success\n");
printf("%i and %i", atoi(row), atoi(column));
}
else
printf("fail\n");
return 0;
}