1

I'm trying to use fgets() to get a string from the user but whenever I run the program it skips right over the fgets(), meaning it won't let me input anything

    printf("*********************************\n");
    printf("             Stock 3\n");
    printf("*********************************\n");

    printf("Enter stock name: ");
    fgets(name,10,stdin);
    printf("Enter the number of shares: ");
    scanf("%d", &share3);
    printf("Enter the buy price, current price, and fees: ");
    scanf("%f, %f, %f", &buy_p3, &current_p3, &fees3);

    puts("");

I believe it has something to do with a \n skipping it but I'm not sure where it is coming from. Any help appreciated. Thanks!

0 Answers0