2D array variable length array?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 650 Views - Last Post: 06 March 2018 - 07:39 AM Rate Topic: -----

#16 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • 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?
Was This Post Helpful? 0
  • +
  • -

#17 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • 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?
Was This Post Helpful? 0
  • +
  • -

#18 XtremeNovice   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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

Was This Post Helpful? 0
  • +
  • -

#19 XtremeNovice   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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?
Was This Post Helpful? 0
  • +
  • -

#20 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • 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.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2