0

My code doesn't take the input of a character in on online C compiler at "programiz.com".

#include <stdio.h>

int main(){
    int a;
    float b;
    char ch;
    char str[100];
    
    printf("Enter an integer : ");
    scanf("%d",&a);
    
    printf("Enter a decimal number : ");
    scanf("%f",&b);
    
    printf("Enter a character : ");
    scanf("%c",&ch);
    
    printf("Enter a string : ");
    fflush(stdin);
    fgets(str,100,stdin);
}

It directly jumps from taking decimal input to string, and I don't know why.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
sudhanshu
  • 19
  • 4

0 Answers0