Variable warning set but not used

none shows up twice in this code snippet:

int none[5]; // declared, not set to anything

And then:

none[i] = number1; // a value has been set, but it's not being used for anything

If, for example, you later had:

int foo = none[3];  // <-- the value in none[3] is being used to set foo

or

for(int i = 0; i < 5; i++)
    printf("%d\n", none[i]);   // <-- the values in none are being used by printf

or something to that effect, we would say none is “used”, but as the code is, you have: "none" set but not used; exactly what the compiler said.


In the pastebin link I see your problem:

You wrote this:

for(i=0;i<5;i++)
{
    printf("Question [i]: none[i]+ntwo[i]");

You meant to write this:

for(i=0;i<5;i++)
{
    printf("Question [i]: ", none[i]+ntwo[i]);

Now none is being used and your print is doing something useful…

Leave a Comment