Click here to Skip to main content
15,921,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generaldouble problem Pin
Sirrius23-Sep-03 10:32
Sirrius23-Sep-03 10:32 
GeneralRe: double problem Pin
Joaquín M López Muñoz23-Sep-03 11:04
Joaquín M López Muñoz23-Sep-03 11:04 
GeneralRe: double problem Pin
Sirrius23-Sep-03 13:18
Sirrius23-Sep-03 13:18 
GeneralRe: double problem Pin
David Crow23-Sep-03 16:58
David Crow23-Sep-03 16:58 
GeneralRe: double problem Pin
Sirrius23-Sep-03 18:19
Sirrius23-Sep-03 18:19 
GeneralOrdered Linked List Pin
Sirrius23-Sep-03 10:01
Sirrius23-Sep-03 10:01 
GeneralRe: Ordered Linked List Pin
Joaquín M López Muñoz23-Sep-03 11:00
Joaquín M López Muñoz23-Sep-03 11:00 
GeneralRe: Ordered Linked List Pin
David Crow23-Sep-03 11:20
David Crow23-Sep-03 11:20 
One way would be to modify the insertNode() method, since it always adds to the front of the list. Something like:

void insertNode( string newName )
{	
    node *p, *n, *t;
 
    p = new node;
    p->data = newName;
    p->next = NULL;
 
    // iterate through the list, finding the right insertion spot
    n = first;
    t = first;
    while (NULL != n && p->data > n->data)
    {
        t = n;
        n = n->next;
    }
 
    // re-adjust the pointers

    if (NULL == first)
        // we inserted into an empty list
        first = p;
    else if (n == first)
    {
        // we inserted a new 'first' node
        first = p;
        p->next = n;
    }
    else
    {
        // we inserted an item someplace else, including the end
        t->next = p;
        p->next = n;
    }
}



Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?

GeneralRe: Ordered Linked List Pin
Sirrius23-Sep-03 13:20
Sirrius23-Sep-03 13:20 
GeneralRC2 encryption interoperability between VC++ and VB.NET Pin
sheelag23-Sep-03 8:49
sheelag23-Sep-03 8:49 
GeneralCDaoDatabase and CDaoRecordset for MS Access 2000 Pin
DionChen23-Sep-03 8:00
DionChen23-Sep-03 8:00 
GeneralRe: CDaoDatabase and CDaoRecordset for MS Access 2000 Pin
JWood23-Sep-03 9:57
JWood23-Sep-03 9:57 
GeneralRe: CDaoDatabase and CDaoRecordset for MS Access 2000 Pin
RChin23-Sep-03 10:14
RChin23-Sep-03 10:14 
Generalcreating menus in VC++ dialog application Pin
karteek23-Sep-03 7:39
karteek23-Sep-03 7:39 
GeneralRe: creating menus in VC++ dialog application Pin
David Crow23-Sep-03 8:55
David Crow23-Sep-03 8:55 
QuestionGetClientRect with initial window wrong? Pin
Harco23-Sep-03 6:42
Harco23-Sep-03 6:42 
AnswerRe: GetClientRect with initial window wrong? Pin
cje23-Sep-03 9:00
cje23-Sep-03 9:00 
GeneralMFC ODBC Consumer Wizard Crashes Pin
Matt Gates23-Sep-03 6:22
Matt Gates23-Sep-03 6:22 
General[Message Deleted] Pin
imdx8023-Sep-03 6:05
imdx8023-Sep-03 6:05 
GeneralRe: Iterating Connection Names, Pin
Mike Dimmick23-Sep-03 7:32
Mike Dimmick23-Sep-03 7:32 
Generalwin95 global memory Pin
umarcool23-Sep-03 5:24
umarcool23-Sep-03 5:24 
Generalmenu Pin
sardinka23-Sep-03 4:31
sardinka23-Sep-03 4:31 
GeneralRe: menu Pin
RobJones23-Sep-03 4:56
RobJones23-Sep-03 4:56 
GeneralRe: menu Pin
sardinka23-Sep-03 5:15
sardinka23-Sep-03 5:15 
GeneralRe: menu Pin
RobJones23-Sep-03 5:56
RobJones23-Sep-03 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.