1

I just learned scanf() functions alongside printf() and I'm wondering why my program kept finishing after I typed some characters from my first user input code. Because it kept finishing, I wasn't able to give input to my second user input code.

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

int main()
{

    double nUm;
    char name[100];


    printf("enter number \t:");
    scanf("%lf", &nUm);
    printf("%f\n", nUm);

    printf("enter name \t:");
    fgets(name, 100, stdin);
    printf("%s", name);

    return 0;
}

I tried to change the variables hoping that it would work but still no changes.

eggsui
  • 11
  • 2

0 Answers0