while working on the c project I found the following problem.
I declared a float variable and performed scanf operation on it. The sample code is –
<#include stdio.h>
<#include conio.h>
void main()
{
clrscr();
float foo;
scanf(" %f ",&foo);
//remaining code goes here
getch();
}
I found that the error is due to the spaces given after and before %f in scanf statement.
But I don’t know what is the reason behind it ?
thanks.
I think this may help you a little.
the function
scanfwill read and ignore any whitespace characters encountered before the next non-whitespace character (whitespace characters include spaces, newline and tab characters — see isspace).Also it should be like
#include<stdio.h>not<#include stdio.h>