C Tutorial/Language/Convention

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Clarity

/* poor programming practice */    
    temp = box_x1; 
    box_x1 = box_x2;   
    box_x2 = temp; 
    temp = box_y1; 
    box_y1 = box_y2;   
    box_y2 = temp;

Indentation and Code Format

while (! done) {   
        printf("Processing\n");    
        next_entry();  
    }  
    if (total <= 0) {  
        printf("You owe nothing\n");   
        total = 0; 
    } else {   
        printf("You owe %d dollars\n", total); 
        all_totals = all_totals + total;   
    }