Dynamic jump to label in C

后端 未结 5 939
清酒与你
清酒与你 2021-01-05 01:29

I would like to display the output - numbers 1 to 5, followed by 4-5 infinitely. Is there any way i can pass the value of i(4) instead of the character i in goto1. Or is the

5条回答
  •  逝去的感伤
    2021-01-05 02:05

    Why not do it like this?

    #include 
    #include 
    
    int main(void)
    {
        printf(" num is 1 \n");
        printf(" num is 2 \n");
        printf(" num is 3 \n");
    
        for (;;){
            printf(" num is 4 \n");
            printf(" num is 5 \n");
        }
    
        /* Not reachable, but will silence any compiler warnings about main
         * not returning a value. */
        return EXIT_SUCCESS;
    }
    

提交回复
热议问题