Mark_48 0 Junior Poster in Training

I am trying to ask for a float input and valididate if it is a float if it is... continue, and if it is not ask for another input.

My program tells me my input is invalid, which is correct... it then prints the two statements but it skips the scanf() and dosn't allow me to enter a different value...any help would be greatful.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

float SupVolt;
float Freq;
float Resistor;
float cap;
float inductance;

int main()
{
    printf("Please enter the supply voltage:");
    scanf("%f", &SupVolt );

   if( scanf("%f", &SupVolt ) <= 0 )
        {
            printf("Invalid Input\n");
            printf("Please enter the supply voltage:/N");
            scanf("%f", &SupVolt );
        }

    printf("continue");

    return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.