int c = 0;
while(fgets(buffer, BUFFER_SIZE, fp) >= 48 && <= 57 ){
printf("%c", c);
}
1)
fgets
returns a pointer to the buffer. It is highly unlikely that the address of the buffer will be between 48 and 57
2) The code
&& <= 57
is not valid C. Every comparison operator requires a left side and a right side. C does not string operators together like that.
3) What are the magic numbers 48 and 57? if you mean '0' and '9' use them, it will make it easier to understand when you review the code later on.
4) You never assign anything to
int c
, so this will always output a 0.
You probably want to look at the function
atoi()
, which will convert ascii strings to integers. Then you'll probably want to write a function that determines if an integer is a perfect square or not. For that, you might need to look at the
sqrt()
function.
For bonus points, you might want to think what you should do if the input line is something like "41Z3Q".