warning: unused variable 'a' [-Wunused-variable] in arrangement

0

The program has to show the number of elements that make up the array compiles and gives the result well but this warning appears

warning: unused variable 'a' [-Wunused-variable]

The error may be due to the fact that the arrangement is not shown, but I am not interested in showing the arrangement, only its number of elements. Is there any way to correct that warning without showing the fix?

#include <stdio.h>
#include <conio.h>
#define TAMANIO 12

/* la función main comienza la ejecución del programa */
int main()
{
    /* utiliza una lista de inicialización para inicializar el arreglo */
    int a[ TAMANIO ] = { 1, 3, 5, 4, 7, 2, 99, 16, 45, 67, 89, 45 };
    int i; /* contador */        
    int total = 0; /* suma del arreglo */

    /* suma el contenido del arreglo a */
    for ( i = 0; i < TAMANIO; i++ ) {
        total += 1;
    } /* fin de for */

    printf( "El total de los elementos del arreglo es %d\n", total );
    getchar();
    return 0; /* indica terminación exitosa */

} /* fin de main */
    
asked by Alejandro Caro 08.10.2018 в 18:16
source

1 answer

-1

The warning is because the fix is not displayed. One of the ways to correct this warning is to go through the arrangement and show it.

The other way to correct the warning is to specify that the variable total refers to the total number of elements of the array a . If you do not want to show the arrelgo, you must specify that the tital refers to the total of the% a .

It would look like this: printf( "El total de los elementos del arreglo es %d\n", total[a]);

    
answered by 15.10.2018 в 22:18