Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Doubly Linked List for MRU to LRU Cache

Posted on 2004-10-31
13
Medium Priority
?
688 Views
Last Modified: 2013-12-14
Hi,

I need help with a program that is designed to repeatedly input words from the keyboard until a blank line is input, while maintaining a list of the 5 most recent words (using a doubly linked list) in such a way that if a word is input that is not already in the list and the list has less than 5 words, the new word is added to the top of the list. If the list already has 5 words in it, the word on the bottom of the list must be removed and the new word must be added to the top of the list. If the new word is already in the list, it must be moved to the top.

The output should look like:

input a word: bob
the lru cache from mru to lru equals: bob
input a word: ted
the lru cache from mru to lru equals: ted bob
input a word: carol
the lru cache from mru to lru equals: carol ted bob
input a word: alice
the lru cache from mru to lru equals: alice carol ted bob
input a word: ted
the lru cache from mru to lru equals: ted alice carol bob
input a word: joe
the lru cache from mru to lru equals: joe ted alice carol bob
input a word: jane
the lru cache from mru to lru equals: jane joe ted alice carol
input a word: carol
the lru cache from mru to lru equals: carol jane joe ted alice
input a word: joe
the lru cache from mru to lru equals: joe carol jane ted alice
input a word:
the program is over

The following is what I have been able to come up with. For syntax reasons that I haven't yet been able to figure out, the program won't compile. However, I highly suspect that there may be flaws within this program beyond syntax that will prevent it from producing the desired output. I would appreciate if anyone could review what I have written to try to spot the errors that I haven't been able to find and provide comments and advice with regard to how I may fix the problems, syntax or otherwise.

Thank You.

#include <iostream>
#include <string>
using namespace std;

const int m=5;

struct Node {
     string word;
     Node *leftPtr, *rightPtr; }

void CreateList(Node *&firstPtr, Node *&lastPtr, int *m);
void InsertNode(Node *&firstPtr, Node *&lastPtr, Node *InsertionPtr, Node *Ptr);
Node *RandomInsertionPoint(Node *firstPtr);
void OutputList(Node *firstPtr);

int main(void)
{
     Node *firstPtr=0; *lastPtr=0;
     int counter=0;
     CreateList(firstPtr, lastPtr, counter);
     printf("the program is over");
     return 0;
}

void CreateList(Node *&firstPtr, Node *&lastPtr, int *counter)
{   cout<<"input a word: ";  
     while(cin.peek() != '\n')
     {    string s;
          cin>>s;
          for(Node *testPtr=firstPtr; testPtr!=NULL; testPtr=testPtr->rightPtr)
          {     if(s==testPtr->word)
                {                                   /* If word present in list, move word to top of list */
                  testPtr->leftPtr = 0;
                  testPtr->rightPtr = firstPtr->rightPtr;
                  firstPtr=testPtr->word;                    
                  return; } }
        Node *Ptr = new Node;       /* Create new node if word not in list */
        Ptr->word = s;
        InsertNode(firstPtr,lastPtr,RandomInsertionPoint(firstPtr),Ptr);
        if(counter==m)                  
             lastPtr = lastPtr->leftPtr;      /* If words in list =5, delete last node in list */       
        else
            counter = counter +1; }        /* If words in list < 5, increment coutner */
        OutputList(firstPtr);          
        cin.get(); }

void InsertNode(Node *&firstPtr, Node *&lastPtr, Node *InsertionPtr, Node *Ptr)
{       if(InsertionPtr==0)
       {       Ptr->leftPtr = 0;
               Ptr->rightPtr = firstPtr;
               if(lastPtr==0)
                       lastPtr = Ptr;
               else
                       firstPtr->leftPtr=Ptr;
               firstPtr = Ptr; }
       else                                // Insert node to the right of InsertionPtr
       {       Ptr->rightPtr = InsertionPtr->rightPtr;
               Ptr->leftPtr = InsertionPtr;
               if(InsertionPtr->rightPtr != 0)
                       InsertionPtr->rightPtr->leftPtr = Ptr;
               else
                       lastPtr = Ptr;
               InsertionPtr->rightPtr = Ptr; } }

Node *RandomInsertionPoint(Node *firstPtr)
{       for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
               if(rand()%2) return Ptr;
       return 0; }

void OutputList(Node *firstPtr)
{      cout<<"the lru cache from mru to lru equals: ";
       for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
               cout<<Ptr->word<<" ";
       cout<<endl; }
0
Comment
Question by:Coconut77840
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
13 Comments
 

Expert Comment

by:skiritis13
ID: 12459216
HI( and sorry for any mistypings )

Just by reading some of your code i see some obvious syntax mistakes.

> void CreateList(Node *&firstPtr, Node *&lastPtr, int *m);

What's with the ampersand '&'?
You must choose, my friend, whether you want  "firstPtr" to be a Node*,hence pointer to a Node, or Node&, hence an instance of a Node. Anyway, here the more obviously correct version is:
> void CreateList(Node *firstPtr, Node *lastPtr, int *m);
The same goes for InsertNode.

Another, not so obvious mistake, but not because of its insignificance, is:
> struct Node {
     string word;
     Node *leftPtr, *rightPtr; }

There is a semicolon ';' missing from the end of the struct's declaration.
Every struct's and class's declaration should be followed by a ';'
So:
> struct Node {
     string word;
     Node *leftPtr, *rightPtr; };

Continue:
> int main(void)
> {
>    Node *firstPtr=0; *lastPtr=0; <<<<<<<<<<<<
>     int counter=0;
>     CreateList(firstPtr, lastPtr, counter);
>     printf("the program is over");
>     return 0;
}

If you want to make multiple declaratons( in one or more lines ) you do them using commas ','
>    Node *firstPtr=0, *lastPtr=0;
Otherwise you should have typed:
>    Node *firstPtr=0; Node *lastPtr=0;

Continue:
I do not know why but the third param of CraeteList is a pointer to an int( int* ).
And i read more of the code i can't see why this is so...
So i guess that you really wanted just an int.
So you should type:
> void CreateList(Node *firstPtr, Node *lastPtr, int m);

(( and i just so that in the definition you have:
> void CreateList(Node *firstPtr, Node *lastPtr, int *m);
and at the declaration:
> void CreateList(Node *firstPtr, Node *lastPtr, int *counter);
Try to give the param variables the same names in the defintion and the declaration ))

And the last:
> firstPtr=testPtr->word;  Line 35
I think you ment:
> firstPtr->word = testPtr->word;

With the chages i just mentioned your programme compiles and runs in my machine!
I hope I helped...

I give you the full code that worked for me:

#include <iostream>
#include <string>
using namespace std;

const int m=5;

struct Node {
     string word;
     Node *leftPtr, *rightPtr; };

void CreateList(Node *firstPtr, Node *lastPtr, int m);
void InsertNode(Node *firstPtr, Node *lastPtr, Node *InsertionPtr, Node *Ptr);
Node *RandomInsertionPoint(Node *firstPtr);
void OutputList(Node *firstPtr);

int main(void)
{
     Node *firstPtr=0, *lastPtr=0;
     int counter=0;
     CreateList(firstPtr, lastPtr, counter);
     printf("the program is over");
     return 0;
}

void CreateList(Node *firstPtr, Node *lastPtr, int counter)
{   cout<<"input a word: ";  
     while(cin.peek() != '\n')
     {    string s;
          cin>>s;
          for(Node *testPtr=firstPtr; testPtr!=NULL; testPtr=testPtr->rightPtr)
          {     if(s==testPtr->word)
                {                                   /* If word present in list, move word to top of list */
                 testPtr->leftPtr = 0;
                 testPtr->rightPtr = firstPtr->rightPtr;
                 firstPtr->word = testPtr->word;                
                 return; } }
        Node *Ptr = new Node;       /* Create new node if word not in list */
        Ptr->word = s;
        InsertNode(firstPtr,lastPtr,RandomInsertionPoint(firstPtr),Ptr);
        if(counter==m)                
             lastPtr = lastPtr->leftPtr;      /* If words in list =5, delete last node in list */      
        else
            counter = counter +1; }        /* If words in list < 5, increment coutner */
        OutputList(firstPtr);          
        cin.get(); }

void InsertNode(Node *firstPtr, Node *lastPtr, Node *InsertionPtr, Node *Ptr)
{       if(InsertionPtr==0)
       {       Ptr->leftPtr = 0;
               Ptr->rightPtr = firstPtr;
               if(lastPtr==0)
                       lastPtr = Ptr;
               else
                       firstPtr->leftPtr=Ptr;
               firstPtr = Ptr; }
       else                                // Insert node to the right of InsertionPtr
       {       Ptr->rightPtr = InsertionPtr->rightPtr;
               Ptr->leftPtr = InsertionPtr;
               if(InsertionPtr->rightPtr != 0)
                       InsertionPtr->rightPtr->leftPtr = Ptr;
               else
                       lastPtr = Ptr;
               InsertionPtr->rightPtr = Ptr; } }

Node *RandomInsertionPoint(Node *firstPtr)
{       for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
               if(rand()%2) return Ptr;
       return 0; }

void OutputList(Node *firstPtr)
{      cout<<"the lru cache from mru to lru equals: ";
       for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
               cout<<Ptr->word<<" ";
       cout<<endl; }
0
 

Expert Comment

by:skiritis13
ID: 12459294
I'm sorry my friend to bother you again... but i'm not quite finished.
I noticed that you don't free the memory you allocate( using the new operator ).
You should keep in mind that "for every new you make, a delete must follow".
You should add a function that deletes the list, like that:
> void DeleteList(Node *firstPtr)
> {
>       Node *temp = 0;
>       while( firstPtr != 0 )
>       {
>             temp = firstPtr;
>             delete temp;
>             temp = 0;      // always zero empty pointers
>             firstPtr = firstPtr->rightPtr;
>       }
> }
0
 

Author Comment

by:Coconut77840
ID: 12459363
Hi skiritis13,

I appreciate your insight and very helpful comments. Your corrected program does compile, which is more than I can say for mine. However, it becomes evident when I compile your program that I have incorrectly placed the loop that repeats the program. For example, the prompt appears for the first input, but the program termiates immediately after I input the first word and the output of the list empty. I realize this is due to a flaw that specifically has to do with the "while(cin.peek() != '\n')" line in the beginning of my CreateList function. Any ideas would be helpful on how this loop should correctly be placed.
 
I would also like to comment on two points you made in your correction.

(1) "void CreateList(Node *&firstPtr, Node *&lastPtr, int *m);"  "What's with the ampersand '&'?"
I, too, found this syntax strange when I read it in my professor's notes. I used it only because he has incorporated it into some of the examples in his notes, and I basically took his word for it. Do you have any ideas why he might have preferred this syntax over the one you pointed out? Personally, I find your version to make more sense.

(2) "I do not know why but the third param of CreateList is a pointer to an int ( int* )"
I wrote the third parameter this way because I wanted to keep track of the counter, and didn't want to lose its value after the function terminated. I see now that you might have changed it to a regular int since the function is only called one time.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Coconut77840
ID: 12459381
skiritis13,

Would I call the DeleteList function this way?

int main(void)
{
     Node *firstPtr=0, *lastPtr=0;
     int counter=0;
     CreateList(firstPtr, lastPtr, counter);
     DeleteList(firstPtr);
     printf("the program is over");
     return 0;
}
0
 

Expert Comment

by:skiritis13
ID: 12459864
My friend I wrote a programme that does the work you want to be done.
Here it is:

#include <iostream>
#include <string>
using namespace std;

const int m=5;

struct Node
{
      string word;
      Node *leftPtr;
      Node *rightPtr;

      // constructor
      Node( string w )
      {
            leftPtr = 0;
            rightPtr = 0;
            word = w;
      }
};

Node *firstPtr=0;
Node *lastPtr=0;

void CreateList();
Node* NameAlreadyInTheList(string input);
void OutputList();
void DeleteList();

int main(void)
{
     CreateList();
       DeleteList();
     printf("the program is over\n");
     return 0;
}

void CreateList()
{      
      int counter = 0;
      while(1)
      {
            string input;
            cout << "Input a word: ";
            cin >> input;
            
            // check for exit
            if( input == "exit" )
                  break;

            if( counter == 0 ) // if list is empty
            {
                  firstPtr = lastPtr = new Node(input);
                  // firstPtr->word = input; <- this is now down in the Node constructor
                  counter++; // the same as counter = counter + 1, counter += 1
            }
            else
            {
                  if( counter == 1 ) // if list is not empty
                  {
                        firstPtr = new Node(input);
                        firstPtr->rightPtr = lastPtr;
                        lastPtr->leftPtr = firstPtr;
                        counter++;
                  }
                  else
                  {
                        Node* ret = NameAlreadyInTheList(input);
                        if( ret )
                        {
                              if( ret != firstPtr )
                              {
                                    Node* left = ret->leftPtr;
                                    Node* right = ret->rightPtr;

                                    if( left )
                                          left->rightPtr = right;
                                    if( right )
                                          right->leftPtr = left;

                                    ret->rightPtr = firstPtr;
                                    firstPtr = ret;
                              }
                        }
                        else
                        {
                              if( counter == 5 )
                              {
                                    // delete the last name
                                    Node* temp = lastPtr->leftPtr;
                                    delete lastPtr;
                                    lastPtr = temp;
                                    lastPtr->rightPtr = 0;
                                    counter--;
                              }
                              
                              Node* new_node = new Node(input);
                              new_node->rightPtr = firstPtr;
                              firstPtr->leftPtr = new_node;
                              firstPtr = new_node;                              
                              counter++;
                        }
                  }
            }

            OutputList();
      }
}

void OutputList()
{      
      cout << "The lru cache from mru to lru equals: ";
      for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
            cout<<Ptr->word<<" ";

      cout<<endl;
}

void DeleteList()
{
      Node *temp = 0;
      while( firstPtr != 0 )
      {
            temp = firstPtr->rightPtr;
            delete firstPtr;
            firstPtr = temp;
      }

      firstPtr = 0;
      lastPtr = 0;
}

// This function returns 0 if the name
// was not found in the list.
// Else, it returns the the Node with the name
Node* NameAlreadyInTheList(string input)
{
      for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
      {
            if( Ptr->word == input )
                  return Ptr;
      }

      return 0;
}
0
 

Expert Comment

by:skiritis13
ID: 12459969
I may have wrote the programme to help you but don't JUST copy it.
I want you to understand it.
You see, the programme you wanted is a simple one, that needs a double-linked list.
Which means that you must understand the concepts of this data structure.But before you must have some background on Arrays and simple lists, memory management etc.
BUT FIRST OF ALL you must understand POINTERS '*', and its concepts.

This one hopes to make you understand why the idea of making the third param of CreateList pointer was a good one but also why it didn't work.

#include <stdio.h>

void Add( int c )
{
c++;
printf("counter = %d\n", c );
}

void AddByReference( int& c )
{
c++;
printf("counter = %d\n", c );
}

void AddByAddress( int* c )
{
*c++;
printf("counter = %d\n", c );
}

int main()
{
 int counter = 0;
printf("counter initial value: %d\n", counter );

 Add(counter);
 AddByReference(counter);
 AddByAddress(&counter);

 return 0;
}

This code outputs:

counter initial value: 0
counter = 0
counter = 1
counter = 2

Am i right?
0
 

Expert Comment

by:skiritis13
ID: 12459981
I am a fool ..
i made a mistake in the AddByAddress!!! sorry

correct it please

void AddByAddress( int* c )
{
 (*c)++;
 printf("counter = %d\n", *c );
}
0
 

Expert Comment

by:skiritis13
ID: 12460013
I hope you understand.
See how i am passind a variable's address with '&'.
If the param is a pointer variable, and i don't have a pointer variable but an instance variable, i should pass the variable's address using the '&'.
Remember, a pointer to a variable( or a class, or anything ) is just the address of it ( in the programme's stack or in the ram ).
i.e
int sth_else = 0;

if you want the sth_else's address -> int* sth = &sth_else;
Now sth is the sth_else's address and you can change sth_else through the pointer sth like this:
(*sth)++;
This means that you increase what lies in the address sth by one.
Notice the parenthesis().
I have to put the otherwise it means:
*(sth++) and sth++ (increasing a pointer) means that sth value has changed and it no longer points to sth_else.
And do you want to know where it points?
Assume:
int sth_else = 0;
int *sth = &sth_else;
Now sth points to the address of sth_else.
sth++;
Now sth points to the address of sth_else + sizeof(int) bytes.

I hope i helped just a little.
0
 

Accepted Solution

by:
skiritis13 earned 800 total points
ID: 12461461
My friend , a had to make some changes because the programme i sent you had some bugs.
I give you the correct version.
This on eworks whatsoever:

#include <iostream>
#include <string>
using namespace std;

const int m=5;

struct Node
{
     string word;
     Node *leftPtr;
     Node *rightPtr;

     // constructor
     Node( string w )
     {
          leftPtr = 0;
          rightPtr = 0;
          word = w;
     }
};

Node *firstPtr=0;
Node *lastPtr=0;

void CreateList();
Node* NameAlreadyInTheList(string input);
void OutputList();
void DeleteList();

int main(void)
{
     CreateList();
      DeleteList();
     printf("the program is over\n");
     return 0;
}

void CreateList()
{      
     int counter = 0;
     while(1)
     {
          string input;
          cout << "Input a word: ";
          cin >> input;
         
          // check for exit
          if( input == "exit" )
               break;

          if( counter == 0 ) // if list is empty
          {
               firstPtr = lastPtr = new Node(input);
               // firstPtr->word = input; <- this is now down in the Node constructor
               counter++; // the same as counter = counter + 1, counter += 1
          }
          else
          {
                        Node* ret = NameAlreadyInTheList(input);
                        if( ret )
                        {
                              if( ret != firstPtr )
                              {
                                    if( ret != lastPtr )
                                    {
                                          Node* left = ret->leftPtr;
                                          Node* right = ret->rightPtr;

                                          if( left )
                                                left->rightPtr = right;
                                          if( right )
                                                right->leftPtr = left;

                                          ret->leftPtr = 0;
                                          ret->rightPtr = firstPtr;
                                          firstPtr = ret;
                                    }
                                    else
                                    {
                                          Node* temp = lastPtr->leftPtr;                                          
                                          lastPtr->rightPtr = firstPtr;                                                                                    

                                          firstPtr->leftPtr = lastPtr;
                                          firstPtr = lastPtr;
                                          firstPtr->leftPtr = 0;

                                          lastPtr = temp;
                                          temp->rightPtr = 0;
                                    }
                              }
                        }
                        else
                        {
                              if( counter == 1 ) // if list is not empty
                              {
                                    firstPtr = new Node(input);
                                    firstPtr->rightPtr = lastPtr;
                                    lastPtr->leftPtr = firstPtr;
                                    counter++;
                              }
                              else
                              {
                                    if( counter == 5 )
                        {
                             // delete the last name
                             Node* temp = lastPtr->leftPtr;
                             delete lastPtr;
                             lastPtr = temp;
                             lastPtr->rightPtr = 0;
                             counter--;
                        }
                         
                        Node* new_node = new Node(input);
                        new_node->rightPtr = firstPtr;
                        firstPtr->leftPtr = new_node;
                        firstPtr = new_node;                        
                        counter++;
                    }
               }
          }

          OutputList();
     }
}

void OutputList()
{      
     cout << "The lru cache from mru to lru equals: ";
     for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
          cout<<Ptr->word<<" ";

     cout<<endl;
}

void DeleteList()
{
     Node *temp = 0;
     while( firstPtr != 0 )
     {
          temp = firstPtr->rightPtr;
          delete firstPtr;
          firstPtr = temp;
     }

     firstPtr = 0;
     lastPtr = 0;
}

// This function returns 0 if the name
// was not found in the list.
// Else, it returns the the Node with the name
Node* NameAlreadyInTheList(string input)
{
     for(Node *Ptr=firstPtr; Ptr!=0; Ptr=Ptr->rightPtr)
     {
          if( Ptr->word == input )
               return Ptr;
     }

     return 0;
}
0
 

Author Comment

by:Coconut77840
ID: 12466046
Hi skiritis13,

Thank you for all your help. Your comments have been extremely helpful and I appreciate the time you took to help.

Thanks again.  
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 12468743
I was a little late, but maybe you find time to look at my solution as well:

#include <iostream>
#include <string>
using namespace std;

// forward declaration
template <class T>
class DLList;

template <class T>
class Node
{
    T     data;
    Node* pPrev;
    Node* pNext;
   
    Node(T t) : data(t), pPrev(NULL), pNext(NULL) {}

    bool operator == (const Node& node) const
    {
        return data == node.data;
    }

    friend class DLList<T>;
};


template <class T>
class DLList
{
    Node<T>* pFirst;
    Node<T>* pLast;
    T empty;
public:

    DLList(const T& t) : pFirst(NULL), pLast(NULL), empty(t) {}
    virtual ~DLList()
    {
        Node<T>* p = pFirst;
       
        while (p != NULL)
        {
            Node<T>* pPrev = p;
            p = p->pNext;
            delete pPrev;
        }
    }

    void setEmpty(const T& t) { empty = t; }
     
    void put(const T& t)
    {
        Node* pNew = new Node(t);
        if (pLast == NULL)
            pFirst = pLast = pNew;
        else
        {
            pLast->pNext = pNew;
            pNew->pPrev = pLast;
            pLast = pNew;
        }
    }
    void push(const T& t)
    {
        Node<T>* pNew = new Node<T>(t);
        if (pFirst == NULL)
            pFirst = pLast = pNew;
        else
        {
            pFirst->pPrev = pNew;
            pNew->pNext   = pFirst;
            pFirst = pNew;
        }
    }
    T getFirst() { return (pFirst == NULL) ? empty : pFirst->data; }
    bool remove(const T& t)
    {
        Node<T>* p = pFirst;                
        while (p != NULL)
        {
            if (*p == t)
            {
                if (p->pPrev != NULL)
                    p->pPrev->pNext = p->pNext;
                else
                    pFirst = p->pNext;
                if (p->pNext != NULL)
                    p->pNext->pPrev = p->pPrev;
                else
                    pLast = p->pNext;
                delete p;
                return true;
            }
            p = p->pNext;
        }
        return false;
    }
    void removeLast()  
    {
        if (pLast != NULL)
        {
            Node<T>* p = pLast;
            if (p->pPrev != NULL)
            {
                pLast = p->pPrev;
                pLast->pNext = NULL;
            }
            else
                pLast = pFirst = NULL;
            delete p;
        }
    }
    void display(const string& sep = "\t", const string& end = "\n" )
    {
        Node<T>* p = pFirst;                
        while (p != NULL)
        {
            if (p->pNext != NULL)
                cout << p->data << sep;
            else
                cout << p->data << end;
            p = p->pNext;
        }
    }
};

template <class T, int MX>
class SizedDLList : private DLList<T>
{
    int mx;
    int cnt;
public:
    SizedDLList(const T& t) : mx(MX), cnt(0), DLList<T>(t) {}

    bool full() { return cnt == mx; }
    void insert(const T& t)
    {
       if (getFirst() == t)
           return;
       if (DLList<T>::remove(t))
           cnt--;
       else if (full())
       {
           removeLast();
           cnt--;
       }
       cnt++;
       push(t);
    }
    void display(const string& sep = "\t", const string& end = "\n" )
    {  
        cout << cnt << ": ";
        DLList<T>::display(sep, end);
    }
};

bool getStringInput(string& input)
{
    cout << "Please Enter Name [quit to leave]==>";
    cin >> input;
    return input != "quit";
}

int main()
{
   string input;
   SizedDLList<string, 5> sdll(input);

   while (getStringInput(input))
   {
       sdll.insert(input);
       sdll.display();
   }
   return 0;
}

Regards, Alex
0
 

Author Comment

by:Coconut77840
ID: 12520090
Alex,

I'm sorry, but I have already given away all the points.

Thank you, nevertheless, for your time. I have looked over your solution and it has helped.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 12521080
Thank you, for the positive feedback.

Regards, Alex
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question