0

i have this for loop in my program that i am creating but it is counting further than it is supposed to and trying to call to an unknown variable thus creating an error. here is the code that kicks back the error.

for (i = 1; i <= me.spellcasterlevel; i++){
                    if (me.firelevel >= i){
                            //cout << i << ": " << me.fire[i].name << endl;
                    }
                }
                cin >> choice;
2
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by Dave Sinkula
0

that is basically what i did, (p.s. this is in c++ incase u were wondering) i declared a starting point, i=1, declared the stoping point, when it hits me.spellcasterlevel, then i said what to do (go up), i++. at least that is what i thought it is.

0
#include <stdio.h>

int main()
{
   int i, array[5] = {10,20,30,40,50};
   puts("right");
   for (i = 0; i < 5; ++i)
   {
      printf("array[%d] = %d\n", i, array[i]);
   }
   puts("wrong");
   for (i = 1; i <= 5; ++i)
   {
      printf("array[%d] = %d\n", i, array[i]);
   }
   return 0;
}

/* my output
right
array[0] = 10
array[1] = 20
array[2] = 30
array[3] = 40
array[4] = 50
wrong
array[1] = 20
array[2] = 30
array[3] = 40
array[4] = 50
array[5] = 1245112
*/
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.