|
All,
I need to implement a circular linked list of circular linked lists. I can generate the individual linked lists just fine but can't quite figure out how to link the lists together. My node has pointers to a right node and a down node. So, a list would be node->right to node->right etc, but I can't figure out how to link a list using the down pointer without loosing the pointer to the first node. Any advice?
Thanks in advance (and I hope this makes sense...)
John
|
|
|
|
|
The solution is to think in 3D.
First, consider that you have a circle of cells. This represents the top level linked list. Each cell contains an index number (integer) and a pointer to the next node of the circle. This linked list is called 'primary list'.
Now, enhance each of these cells so that they also contain a second pointer. Each of these cells becomes the first cell of a secondary linked list that rotates from the 2D plane up, does a circle, and returns down again. The second pointer points to the next cell of the secondary linked list.
Here is a declaration of the cell structure
struct Node {
int nNumber;
element_type* ptrNext;
element_type* ptrDown;
}; The primary linked list has valid values in all entries. ptrNext points to the next cell in the primary list, and ptrDown points to the next cell in the secondary list. The secondary list has two types of cells:
a) Members of the primary and secondary lists, with valid values in all entires
b) Members of the secondary list only, with a NULL value in ptrNext
In the primary list, the nNumber entry contains an index number that identifies an individual list from the chain, e.g. list at index position 1. In order to keep it simple, you could use negative values in the primary chain, and positive values in secondary chains. This would make it easy to identify any given cell: if it's value is negative, it's the linking cell between a secondary and a primary list. If it's positive, it's an individual cell in some secondary list.
If the above was implemented, then those cells with negative values would be the headers of the secondary lists, as stated in ADT language. The primary linked list might also have a header. This header's ptrDown value should be NULL, or index value should be 0, to seperate it from the other members of the primary list and the members of the secondary lists.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm trying ot write a IRC program and I've hit a snag. Getting the string into pieces is tough for me, I've tried strtok, memcopy, copymemory, all that crap and I just can't seem to get it right, the program just crashes.
This is basicly what I need to parse:
:Nick!Stuff@=HostOrSomething.eggormuffin PRIVMSG #channel :hi\r\n
I need to get it into:
Nick
PRIVMSG
#channel
hi
If you could give me some advice, some code, or an article I would greatly appreciate it
wWw.KruncherInc.cOm
|
|
|
|
|
Why dont u write your own parsing function.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
What's wrong with:
CString strSource = ":Nick!Stuff@=HostOrSomething.eggormuffin PRIVMSG #channel :hi\r\n",
str1,
str2,
str3,
str4;
AfxExtractSubString(str1, strSource, 0, '!');
AfxExtractSubString(str2, strSource, 1, ' ');
AfxExtractSubString(str3, strSource, 2, ' ');
AfxExtractSubString(str4, strSource, 2, ':');
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Because I am using WIN32 API, no MFC.
wWw.KruncherInc.cOm
|
|
|
|
|
Technically, MFC is also using the WIN32 API, but your point is taken nonetheless. I like to say that an apple is a fruit, but a fruit is not an apple.
Try this for starters:
LPCSTR lpszSource = ":Nick!Stuff@=HostOrSomething.eggormuffin PRIVMSG #channel :hi\r\n",
lpszPtr;
TCHAR szStr1[32],
szStr2[32],
szStr3[32],
szStr4[32];
lpszPtr = strchr(lpszSource, '!');
lstrcpyn(szStr1, lpszSource, lpszPtr - lpszSource + 1);
lpszSource = lpszPtr + 1;
lpszPtr = strchr(lpszSource, ' ');
lpszSource = lpszPtr + 1;
lpszPtr = strchr(lpszSource, ' ');
lstrcpyn(szStr2, lpszSource, lpszPtr - lpszSource + 1);
lpszSource = lpszPtr + 1;
lpszPtr = strchr(lpszSource, ' ');
lstrcpyn(szStr3, lpszSource, lpszPtr - lpszSource + 1);
lpszSource = lpszPtr + 2;
lpszPtr = strchr(lpszSource, '\r');
lstrcpyn(szStr4, lpszSource, lpszPtr - lpszSource + 1);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
ok, what you need to do is go make a loop to go thorugh each character of the string
im assuming the first character is alwase going to be a ":"
so i would start at position 1 (the second character)
you know the whats between ":" and "!" is the user name (i assume) so make a variable for the user name
if you havent hit a "!" then add that character into the variable for user name,
what i would do is make a an array like
char szMsgInfo[3][512];
szMsgInfo[0] (Username)
szMsgInfo[1] (PRIVMSG)
szMsgInfo[2] (#channel)
szMsgInfo[3] (message)
have a variable to store what element you are on,
if you hit a ":" then you are on 0
if you hit a "!" then you are on 1
when you hit a " " then you are on 2
when you hit another " " then you are on 3
then when you hit another ":" you are on the message
hope that helped some
|
|
|
|
|
What is the easiest way for changing CButton (MFC) text control??
Please help
|
|
|
|
|
the only way i know of is to use CreateFont
|
|
|
|
|
can do it by using CWnd::OnCtlColor. Have a look @ the MFC Library Reference @ msdn
|
|
|
|
|
Hi guys,
Can anybody give me any pointers on how to make an mfc/C++ application upgradable? I've written the app, created a setup project, and am about to distribute it. But if in two months time i want to release an upgrade to my program, what should I do?
I have absolutely no idea how upgrades work, or what I have to do to make my application upgradable.
I'd be grateful for any general guidelines or principles about what I should do. I don't need any sample code or anything, just general suggestions about the approaches I might take.
Thanks for your help. i realise this thread is a bit vague, I can provide more information about my app if anybody requests it.
Mick
|
|
|
|
|
Well, you can distribute a new exe, or make a patch that updates the old one. Or load the functionality that you might update from dlls, and update those
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thanks Christian. I realize that just replacing the old exe with a new one is the easiest option, but this is not as elegant as distributing an upgrade that is nice and small, and only replaces the bits of the program that are out of date. So I guess I would like to make "a patch that updates the old one". But how do I do that? Once I have compiled my exe, surely I can't change anything in its code?
Thanks for replying!
Mick
|
|
|
|
|
Oh right, so I think I understand. I have to compile each class as a dll, then replace the dlls that are being upgraded, leaving the remainder as they are?
Mick
|
|
|
|
|
You can do that, choosing just the classes that you're likely to change. Or you can use a tool which basically diffs the two exes ( old and new ) and then makes a program which takes the differences, and merges them into the existing ( old ) app on the client machine.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
In MS Studio VC++ 6.0, I want use the following code to get Local PC IP Address, However IPString is always returned as "0.0.0.0" why???
Thanks for any suggestion.
void CDispipDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CMySocket pp;
CString IPString;
UINT nPort;
pp.Create();
if(pp.GetSockName(IPString,nPort))
{
AfxMessageBox(IPString);
}
else
{
AfxMessageBox("Got an Error");
}
}
|
|
|
|
|
Hi again, I have another problem.
I'm creating a test COM server to learn more about the COM interface.
Now I tried to call call the server via C, and everything works fine.
But when I'm trying to call the server using VBScript then always the same error occurs:
800A01A8 - Object required
The script looks like this:
Dim t
Set t = CreateObject( "atlcom.TestInterface" ) (the interface gets loaded here, I used OutputDebugString to make that sure!)
t.MsgBox "Test" <- this is the error line.
I don't know what is wrong.
Do you have any ideas?
Don't try it, just do it!
|
|
|
|
|
[edit]And why was this post awarded a 1? Did I hurt anybody's feelings or what? [/edit]
VBScript can only handle IDispatch-based COM objects.
BTW, this isn't the best forum for COM questions..
--
Arigato gozaimashita!
|
|
|
|
|
ah thanks, didn't know that!!
Don't try it, just do it!
|
|
|
|
|
|
Hi
I'm trying to design a control, derrived from CStatic with keyboard navigation support. When user press the Tab button I call GetNextDlgTabItem and then SetFocus, but, for example, if the next control in tab order is button it draws inproperly - the focus rect is drawn, but the button does not look as default.
|
|
|
|
|
Hi all, I'm kinda new to C++ and I'm using it to try and understand object orientated programming.
I've got a few classes written which I have copied from a book and stripped down to the bare minimum so I can try and see what is going on. Basically I have 3 classes ( TruckLoad, Box and List ). As far as I understand it List is a aggregation of the Box class so that multiple instances of the Box class can be stored ( container class - I think ). TruckLoad is a class which contains a list of the box objects. So the dimensions of each box are stored in each instance of the box object which is stored in the TruckLoad list.
I am trying to store a list of characters instead of a list of numbers. I tried changing all the 'double' declarations to 'char' but a number of errors were produced. If I wanted to store a list of characters instead of a list of numbers how would I do this? For example when the program is run it produces:
The largest box in the first list is 100 by 100 by 100
Press any key to continue
What I am asking if I wanted to produce the following how would I do it?
The largest box in the first list is one hundred by one hundred by one hundred
Press any key to continue
If you want to take a look at the classes I've put together, you can download all the entire project files here:
www.hostmaster-x.co.uk/c++/
Thank you in advance.
CaptainChainsaw
|
|
|
|
|
I have a dialog in a DLL that I need to set to the system tray. Is that possible and if o how can I do that?
|
|
|
|
|
You mean real dialogs? Like quicklaunch bar?
Don't try it, just do it!
|
|
|
|
|