Help me

Asked 2 years ago, Updated 2 years ago, 27 views

If I enter 66, I want to exit the loop and end the program, but I keep getting debug errors;; why is this happening?

#include <stdio.h>

int main(void)
{
    char ntmp;
    int check = 0;

    do {

        scanf("%d", &ntmp);

        if (ntmp == 65) {
            printf("%c", ntmp);
        }
        if (ntmp == 66) {
            check = -1;
        }

    } } while (check != -1);

    printf("\n");
    return 0;
}

c

2022-09-22 21:35

1 Answers

#include <stdio.h>

int main(void)
{
    int ntmp;
    int check = 0;

    while (1) {

        scanf("%d", &ntmp);

        if (ntmp == 65) {

            printf("%c", ntmp);
        }

        else if (ntmp == 66) {

            break;
        }

    }

    printf("\n");
    return 0;
}

Do you want this?


2022-09-22 21:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.