It's a language question!

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

int main()
{
void quater_sales(void)
{
    int i, j, choice;
    int sum = 0;
    printf("Please enter the quarter number(1.1Q2.2.Q3.3Q4.4Q:");
    choice = getchar() - '0';
    while (getchar() != '\n');
    choice--;
    for (i = 0; i < 4; i++)
        for (j = 0; j < 3; j++)

            sum = sum + sale[i][j][choice];

    printf("%d quarter sales are %d". \n", choice, sum);

}

It's a function to find out the quarterly sales volume, while(getchar()!="\n"); here, I changed "\n" to "\n", and the phenomenon that I received the branch number and stopped was corrected, but I wonder what's the difference between the two.

c

2022-09-22 12:16

1 Answers

"" is usually used to refer to the string ' ' is usually used to refer to char


2022-09-22 12:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.