Click here to Skip to main content
15,914,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linked list Pin
Yulianto.28-Jun-05 22:05
Yulianto.28-Jun-05 22:05 
GeneralRe: Linked list Pin
LiYS28-Jun-05 22:14
LiYS28-Jun-05 22:14 
GeneralRe: Linked list Pin
Yulianto.28-Jun-05 22:19
Yulianto.28-Jun-05 22:19 
GeneralRe: Linked list Pin
LiYS30-Jun-05 16:59
LiYS30-Jun-05 16:59 
GeneralRe: Linked list Pin
LiYS28-Jun-05 22:43
LiYS28-Jun-05 22:43 
GeneralRe: Linked list Pin
Yulianto.28-Jun-05 22:56
Yulianto.28-Jun-05 22:56 
GeneralRe: Linked list Pin
John R. Shaw29-Jun-05 8:19
John R. Shaw29-Jun-05 8:19 
GeneralRe: Linked list Pin
David Crow30-Jun-05 3:47
David Crow30-Jun-05 3:47 
How about something like:

struct link
{
    // default constructor
    link(){}
    
    link( const int n)
    {
        a = n;
        next = NULL;
    }
    
    int a;
 
    // pointer to next link in list
    link *next;
};
 
// pointers to first and last items in list
struct link *first = NULL;
struct link *last  = NULL;
 
//====================================================================
 
void addhead( struct link *newlink )
{
    if (NULL == last)
        last = newlink;
 
    if (NULL != first)
        newlink->next = first;
 
    first = newlink;
}
 
//====================================================================
 
void addhead( const int num )
{
    struct link *newlink = new struct link(num);
    addhead(newlink);
}
 
//====================================================================
 
void addtail( struct link *newlink )
{
    if (NULL == first)
        first = newlink;
 
    if (last != NULL)
        last->next = newlink;
    
    last = newlink;
}
 
//====================================================================
 
void addtail( const int num )
{
    struct link *newlink = new struct link(num);
    addtail(newlink);
}
 
//====================================================================
 
void main( void )
{
    struct link *list;
 
    // you can also put this in an initialize() function
    for (int x = 0; x < 10; x++)
        addtail(new struct link(x));
    
    // add a few other link (using a number)
    addtail(15);
    addhead(2);
    addtail(288);
 
    // print out the list
    list = first;
    while (NULL != list)
    {
        cout << list->a << endl;
        list = list->next;
    }
}



"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown


GeneralRe: Linked list Pin
LiYS30-Jun-05 17:00
LiYS30-Jun-05 17:00 
GeneralEmbedding tiff in pdf Pin
Chathan28-Jun-05 21:18
Chathan28-Jun-05 21:18 
GeneralProgramFiles Pin
sunit528-Jun-05 21:15
sunit528-Jun-05 21:15 
GeneralRe: ProgramFiles Pin
oustar29-Jun-05 0:14
oustar29-Jun-05 0:14 
GeneralRe: ProgramFiles Pin
David Crow30-Jun-05 3:50
David Crow30-Jun-05 3:50 
QuestionOpening files within a webview without download dialog? Pin
retro_coder28-Jun-05 20:53
retro_coder28-Jun-05 20:53 
GeneralBio- Powered DLL ?? :o Pin
_kane_28-Jun-05 20:36
_kane_28-Jun-05 20:36 
GeneralRe: Bio- Powered DLL ?? :o Pin
Christian Graus28-Jun-05 20:40
protectorChristian Graus28-Jun-05 20:40 
Generala problem!!!! Pin
smartymanav28-Jun-05 20:17
smartymanav28-Jun-05 20:17 
GeneralRe: a problem!!!! Pin
toxcct28-Jun-05 20:30
toxcct28-Jun-05 20:30 
GeneralRe: a problem!!!! Pin
smartymanav28-Jun-05 20:53
smartymanav28-Jun-05 20:53 
GeneralRe: a problem!!!! Pin
toxcct28-Jun-05 20:56
toxcct28-Jun-05 20:56 
GeneralRe: a problem!!!! Pin
smartymanav28-Jun-05 21:02
smartymanav28-Jun-05 21:02 
GeneralRe: a problem!!!! Pin
toxcct29-Jun-05 0:15
toxcct29-Jun-05 0:15 
GeneralRe: a problem!!!! Pin
Cool Ju29-Jun-05 23:42
Cool Ju29-Jun-05 23:42 
GeneralRe: a problem!!!! Pin
smartymanav28-Jun-05 20:57
smartymanav28-Jun-05 20:57 
GeneralRe: a problem!!!! Pin
Christian Graus28-Jun-05 20:37
protectorChristian Graus28-Jun-05 20:37 

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.