Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: interpolation code C++ Pin
ThatsAlok1-Sep-08 20:18
ThatsAlok1-Sep-08 20:18 
QuestionCToolBarCtrl help Pin
fantasy12151-Sep-08 16:31
fantasy12151-Sep-08 16:31 
QuestionCAsyncSocket fails after a few successful OnReceive()'s Pin
EvoWing1-Sep-08 14:28
EvoWing1-Sep-08 14:28 
AnswerRe: CAsyncSocket fails after a few successful OnReceive()'s Pin
EvoWing2-Sep-08 3:55
EvoWing2-Sep-08 3:55 
GeneralRe: CAsyncSocket fails after a few successful OnReceive()'s Pin
Mark Salsbery2-Sep-08 7:05
Mark Salsbery2-Sep-08 7:05 
QuestionRe: CAsyncSocket fails after a few successful OnReceive()'s Pin
EvoWing7-Sep-08 4:55
EvoWing7-Sep-08 4:55 
QuestionRe: CAsyncSocket fails after a few successful OnReceive()'s Pin
Mark Salsbery8-Sep-08 8:17
Mark Salsbery8-Sep-08 8:17 
Questionconcatenate linked list of characters Pin
Sadaiyappan1-Sep-08 13:27
Sadaiyappan1-Sep-08 13:27 
Ok my code is below, my program is working okay so far but I am trying to implement the concatenate function and I have no clue how to do so. I am passing the second list to the concatenate function but I am unsure of how to create a pointer that would point to the first node of that second list object. I have a pointer created that points to the fist node of the first list but I don't know how to make one for the second list. How do I do this?



#ifndef NEWSTRING_H_INCLUDED
#define NEWSTRING_H_INCLUDED

struct Newlist
{
    char data;
    Newlist *next;
};

class listClass
{
    public:
        listClass();
        ~listClass();
        void insert(char);
        void display();
        int length();
        void concatenate(listClass);
        void concatenate(char);
        bool substring(Newlist);
    private:
        Newlist *head;
        Newlist *current;
};

#endif // NEWSTRING_H_INCLUDED




#include <iostream>
#include "Newstring.h"

using namespace std;

listClass::listClass()
{
    head = NULL;
}

listClass::~listClass()
{
	if(head != NULL)
	{
		do
		{

			Newlist *nodePtr = head;

			head = head->next;
			delete nodePtr;
		} while(head!=NULL);
	}
}

void listClass::insert(char value)
{
	 Newlist *insert, *temp;

     insert = new Newlist;

     insert->data = value;

     insert->next = NULL;

     if(head == NULL)
       {
           head = insert;
           current = head;
       }
     else
       {
           temp = head;

           while(temp->next != NULL)
           {
               temp = temp->next;
           }
           temp->next = insert;
       }
}


void listClass::display()
{
    Newlist *displayPtr;

    displayPtr = head;

    while(displayPtr != 0)
    {
        cout << displayPtr->data << endl;
        displayPtr = displayPtr->next;
    }
}

int listClass::length()
{
    Newlist *countPtr;

    int count = 0;

    countPtr = head;

    while(countPtr != NULL)
    {
        count++;
        countPtr = countPtr->next;
    }

    return count;
}

void listClass::concatenate(listClass newlist)
{
    insert(newlist);
}




#include <iostream>
#include "Newstring.h"

using namespace std;

int main()
{
    listClass list;
    listClass newlist;


    list.insert('a');
    list.insert('b');
    list.insert('c');

    list.display();

    cout << list.length() << endl;;

    newlist.insert('d');
    newlist.insert('e');
    newlist.insert('f');

    list.concatenate(newlist);

    list.display();

    return 0;
}</iostream></iostream>

AnswerRe: concatenate linked list of characters Pin
Robert.C.Cartaino1-Sep-08 14:51
Robert.C.Cartaino1-Sep-08 14:51 
QuestionA Global Keyboard hook problem. Pin
emmmatty11-Sep-08 9:33
emmmatty11-Sep-08 9:33 
AnswerRe: A Global Keyboard hook problem. Pin
Naveen1-Sep-08 15:21
Naveen1-Sep-08 15:21 
GeneralRe: A Global Keyboard hook problem. Pin
emmmatty11-Sep-08 18:49
emmmatty11-Sep-08 18:49 
GeneralRe: A Global Keyboard hook problem. Pin
Naveen1-Sep-08 19:00
Naveen1-Sep-08 19:00 
AnswerRe: A Global Keyboard hook problem. Pin
Rajesh R Subramanian1-Sep-08 20:51
professionalRajesh R Subramanian1-Sep-08 20:51 
Questionrand() always returns 18467...whats going on.. [modified] Pin
montiee1-Sep-08 8:47
montiee1-Sep-08 8:47 
AnswerRe: rand() always returns 18467...whats going on.. Pin
Mark Salsbery1-Sep-08 11:20
Mark Salsbery1-Sep-08 11:20 
GeneralRe: rand() always returns 18467...whats going on.. Pin
montiee1-Sep-08 19:23
montiee1-Sep-08 19:23 
QuestionMy application is closing when i hit enter button through keyboard Pin
hariakuthota1-Sep-08 8:12
hariakuthota1-Sep-08 8:12 
AnswerRe: My application is closing when i hit enter button through keyboard Pin
Cedric Moonen1-Sep-08 8:16
Cedric Moonen1-Sep-08 8:16 
AnswerRe: My application is closing when i hit enter button through keyboard Pin
onlyjaypatel1-Sep-08 19:24
onlyjaypatel1-Sep-08 19:24 
Question3D World Pin
MrMcIntyre1-Sep-08 7:34
MrMcIntyre1-Sep-08 7:34 
AnswerRe: 3D World Pin
Cedric Moonen1-Sep-08 7:50
Cedric Moonen1-Sep-08 7:50 
GeneralRe: 3D World Pin
MrMcIntyre1-Sep-08 8:07
MrMcIntyre1-Sep-08 8:07 
GeneralRe: 3D World Pin
Cedric Moonen1-Sep-08 8:14
Cedric Moonen1-Sep-08 8:14 
GeneralRe: 3D World Pin
MrMcIntyre1-Sep-08 9:06
MrMcIntyre1-Sep-08 9:06 

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.