Please Help Me Condense A Small Piece Of Code

i just finished a fairly large program, and now im trying to condense certain parts down (if possible)

I have this at the top of my code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
struct Songs song1; song1.count = 0;
struct Songs song2; song2.count = 0;
struct Songs song3; song3.count = 0;
struct Songs song4; song4.count = 0;
struct Songs song5; song5.count = 0;
struct Songs song6; song6.count = 0;
struct Songs song7; song7.count = 0;
struct Songs song8; song8.count = 0;
struct Songs song9; song9.count = 0;
struct Songs song10; song10.count = 0;
struct Songs song11; song11.count = 0;
struct Songs song12; song12.count = 0;
struct Songs song13; song13.count = 0;
struct Songs song14; song14.count = 0;
struct Songs song15; song15.count = 0;
struct Songs song16; song16.count = 0;
struct Songs song17; song17.count = 0;
struct Songs song18; song18.count = 0;
struct Songs song19; song19.count = 0;
struct Songs song20; song20.count = 0;


Is there anyway to go through a loop to to condense this?
something
for(int i = 1; i <= 20; i++)
{
struct Songs song + i; song + i.count = 0;
}
I know that for loop won't work that way, but is there some way to do something like that?
Have you considered creating an array of songs?

That struct at the start of every line is not necessary.

1
2
3
4
5
6
songArray Songs[20];

for (int i=0;i<20; i++)
{
  Songs[i].count=0;
}
Topic archived. No new replies allowed.