Solved

Multi-dimensional arrays

Posted on 2006-07-18
3
217 Views
Last Modified: 2010-04-15
Ok, Im close to finishing my project and the last problem is to enable Logging.

The project is menu based and the user selects from 5 options and does different stuff. Fine.

However, the logging requirements are to Display the option, the Count of times it has been accessed & the Order its been accessed.

And the Order only stores the last 10 option calls

The example is

OPTION        COUNT         ORDER
    1                  1                  1
    2                  0
    3                  3                   3,4
    4                  10                 2,5,6,7,8,10
    5                  0
    6                  1                   9




So you can from that example, that the user has been using option 4 alot - 10 times & the order has recorded only the last 6 - as it stores only the last 10 option calls.

Hope that explains the problem.


My solution was to have a double array

int sessionLog[6][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};

So the first element would hold the total Count that option has been used and the second is the Order it was accessed. Both could be incremented as needed.


Then *crunch*

I realized that thats fine if each option is only accessed *once*.

So that's my question I need some help with - how could it store multiple accesses? A triple array??

Or what about an array of arrays?

Any ideas?
0
Comment
Question by:Benjamin_Barrett
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 total points
ID: 17131158
How about an array of structs

struct info {
      int option;
      int count;
      int order[10];
}

struct info mydata[6];

This should solve your problem ...

You can ofcourse use a linked list for order[]
0
 

Author Comment

by:Benjamin_Barrett
ID: 17131174
Good idea, I'll try it out get back to you.....
0
 

Author Comment

by:Benjamin_Barrett
ID: 17131952
Excellent, many thanks SunnyCoder.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now