SaMax
SaMax

Reputation: 169

scanf is returning 2, not true

int main(void){
    float f=0,ff=0;
    if (scanf("%f %f",&f,&ff) == 2){
        printf("True\n%f %f",f,ff);fflush(stdout);
    } else{
        printf("False\n%f %f",f,ff);fflush(stdout);
    }

    getchar();
    return 0;
}

If my input is "6.81 7.kj" it returns true!!

Upvotes: 2

Views: 169

Answers (1)

7. is a valid float. The fact that there's more input left is irrelevant to the success of the call.

Upvotes: 3

Related Questions