Advertisement

problem with this loop and list

Started by May 17, 2001 11:39 AM
1 comment, last by omegasyphon 23 years, 8 months ago
alright i have my 100 element list created int list[100]={0}; for (x=0;x<100;x+=4) { list[x]=y; list[x+1]=y+1; list[x+2]=y+11; list[x+3]=y+10; y++; } now when i go to run this code and output the array to a file the array stops after 36 and im not sure why
  int list[100]={0}; // waste of initialization                   // why initialize everything to zero when                   // in the very next line you set it to                   // something else?for (x=0;x<100;x+=4) // this will run 100/4 = 25 times{    list[x]=y;       // what''s y initialized to?    list[x+1]=y+1;    list[x+2]=y+11;    list[x+3]=y+10;    y++;             // whatever it is, it''s 25 more when it''s                     // done}  

quote:

now when i go to run this code and output the array to a file
the array stops after 36 and im not sure why


What does it look like in memory, before it goes to the file? If it looks right, then the problem is in your output code, not your initialization code. What do you mean it "stops after 36"? What stops? Is 36 a value or an index?


Advertisement
i figured out my problem, my loopin value was wrong

This topic is closed to new replies.

Advertisement