# 2D array variable length array?

• (2 Pages)
• 1
• 2

## 19 Replies - 525 Views - Last Post: 06 March 2018 - 07:39 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=409595&amp;s=5257c227480649cfe29ef06ca03bdcea&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 modi123_1

• Suitor #2

Reputation: 13857
• Posts: 55,328
• Joined: 12-June 08

## Re: 2D array variable length array?

Posted 04 March 2018 - 01:10 PM

What about the other for loop I mentioned?

### #17 modi123_1

• Suitor #2

Reputation: 13857
• Posts: 55,328
• Joined: 12-June 08

## Re: 2D array variable length array?

Posted 04 March 2018 - 01:26 PM

You should also revamp/review the entire logic. You don't need a for loop inside a for loop.
You need to review how you are getting values from the array.

Things like the 'average' should be done AFTER you get the total sum of the song lengths.

Then there's these..
```006	#define SONG_LENGTH 1
007	#define SONG_COLUMNS 2
```

.. used here:
```038	        fscanf(stdin,"%d", &(songs[i][SONG_GENRE]));
039
040	        fprintf(stdout,"  Length of song: ");
041	        fscanf(stdin,"%d", &(songs[i][SONG_LENGTH]));

```

Does it make sense to be using 1 and 2 when arrays start counting at 0 and then 1?

### #18 XtremeNovice

Reputation: 0
• Posts: 18
• Joined: 05-February 18

## Re: 2D array variable length array?

Posted 05 March 2018 - 09:45 PM

I didn't know you responded... someone else from this website suggested to use those define statements, which I'm pretty sure I haven't been over in class yet. the way I have it set up it is accumulating the songLength and it was working for avg. I never changed those statements and now its not working. there is too many problems with this project. I mean I literally just started learning how to code like a month ago.

This post has been edited by XtremeNovice: 05 March 2018 - 09:52 PM

### #19 XtremeNovice

Reputation: 0
• Posts: 18
• Joined: 05-February 18

## Re: 2D array variable length array?

Posted 05 March 2018 - 10:23 PM

so the numbers next to #define SONG_LENGTH refers to the index?

### #20 modi123_1

• Suitor #2

Reputation: 13857
• Posts: 55,328
• Joined: 12-June 08

## Re: 2D array variable length array?

Posted 06 March 2018 - 07:39 AM

Correct. You are defining a word constant name to represent a number to ease up on readability, etc.