#Why c99 mode ?

16 messages · Page 1 of 1 (latest)

languid elbow
#

I compile with vscode and falcon

code c

if (int)
iron sableBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dull eagle
#

Are you done writing?

languid elbow
#

no error

#

eh

#

I mean code with if (int) when run will appear c99

#

examples

#include <stdio.h>
#define daily_calorie_limit 2000

int main(){
    int number_of_meals = 3;
    float calories, total_calories = 0;

    //  Title
    printf("\n=== Daily Calorie Counter Program ===\n");
    printf("This program will calculate the total daily calories consumed\n");

    //  Input
    for(int a = 1; a <= number_of_meals; a++ ){
        printf("Enter the calories for meal number: %d\n", a);
        scanf("%f", &calories);
        total_calories += calories;
    }

    printf("\nTotal calories: %.0f\n");

    if(total_calories > daily_calorie_limit){
        printf("Total calories exceed the daily limit");
    }
    
    else{
        printf("Total calories are within the daily limit");
    }

    return 0;
}
glad sand
#

Not much to add really.
If you want to introduce new variables within the scope of your function then you must use C99 or later.
Your compiler appears to default to C89.

languid elbow
glad sand
#

No, it's nothing to do with the hardware.
Just configure your project / makefile to use the C99 standard or later.

#

Unless your compiler is so old that it only understands C89....

#

I don't know what build system you may be using.
Look around for a tab / page containing compiler settings and look for drop down options where you select the C standard.
Or perhaps there is a free-form field for "additional compiler options" or words to that effect where you can type "-std=c99".

rotund spade
#

as nowadays it defaults to C17

#

not sure what part that Falcon thing plays here in the picture