What data type to use?

I`m trying to think for a nice way to handle my problem, but have come up with nothing.
I have a table of web pages users have viewed. This table has two colomns UsrID and PageURL. I want to select UsrID and PageURL of all users that answer a certain criteria. Up till here everything is easy.
My problem is that I need to pass this data to unmanaged c++ code and I can`t think of a data type that will do this nicly.
The only thing I have been able to come up with is creating an array of strings, with each string holding a comma seperated list of all visited web pages for a single user.
This is a very ugly way to do it, but I can`t think of anything nicer.
Hope maybe someone here can help.
Thank you in advance for any help you can supply.
Who is Participating?
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
Actually just requires a minor extension.
Use a single zero to separate items, a double zero to inicate another user and a triple zero for the termination.
User Andy visits www.ainscow.ch
User Benny visits www.xyz.com and www.someothersite.com

string is

the 0 are actually a zero NOT the character '0'
Actually a comma-separated list is not really a good idea, since commas are valid characters in URLs also. Depending on the way you want to call the unmanaged code, I'd suggest to go for VARIANTs that hold BSTRs with COM interop. You could either pass an array of VARIANTs or VARIANTs that contain SAFEARRAYs of BSTRs.
EladlaAuthor Commented:
Thanks for the comment.
First of all I have no commas in my urls, so that isn`t going to be a problem.
What you are suggesting is an array of arrays?
Could I pass that from VB to c++ or is that going to be trouble?
I want to use the least amount of platform specific code that I can and I guess working with variant and safearray will not help me in that respect.
Any other ideas?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

AndyAinscowFreelance programmer / ConsultantCommented:
One way that windows handles this type of problem (I think) is to have a string (char x[2048] for example) and use the value 0 to separate individual values and  a 00 to indicate the end of the string.
Could that be suitable for you?
tou can use this format:

EladlaAuthor Commented:
Nice ideas...but I`m looking for something more creative if possible.
AndyAinscowFreelance programmer / ConsultantCommented:
I could give you some very creative ideas if you really wanted.  Personally I prefer the simplest that works efficiently (easy to code, easy to maintain, easy for others to understand).  Is there anything about my suggestion which rules it out?
EladlaAuthor Commented:
Well.....to all intents and purposes your idea is just a more complex version of my idea.
Since I decided my idea will be a last resort...I`m trying to find maybe a nicer way than an array of string each holding a comma seperated list (or anything similar to that)
So to answer your question, I really want something more creative.
AndyAinscowFreelance programmer / ConsultantCommented:
I don't mention array at all.  I talk about ONE string variable and only one string variable to store everything in it.
AndyAinscowFreelance programmer / ConsultantCommented:
AFAIK a zero wouldn't be a valid character so that is used as a separator between the fields. Two zeros next to one another determine the total length of the string buffer in use for the recipient.
EladlaAuthor Commented:
I see.....well....what I need to store in this data type is a list of all visited pages grouped by the visiting user.
I don`t see how your idea does this, please alaberate.
AndyAinscowFreelance programmer / ConsultantCommented:
I have just reread your question in light of your last comment.  I had misunderstood, I thought the list you wanted was one user, one page, next user, next page...

OK forget the suggestion then.
EladlaAuthor Commented:
Sounds good....
I`ll try it out and see if it isn`t too inefficient.
I would be more comfortable with an integer array based solution...if thats possible
in this scenario.
AndyAinscowFreelance programmer / ConsultantCommented:
By integer array based do you mean
int x[2048] instead of char x[2048]
for the packed information?

if yes then it is basically just the same.

efficiency - memory usage should be better than a collection of arrays, to unpack you just increment a pointer to pick off where the next string begins (don't forget that zero is used as the normal termination character for a string).  To pack it is similar.
EladlaAuthor Commented:
ok....I`ll take that.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.