1

I'm trying to practice my C++ and I wanted to start off creating a simple linkedlist. I'm doing this in Visual Studio and I'm having a hard time trying to debug this little program. When I run the program all I get are:

'LinkList.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'LinkList.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'LinkList.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'LinkList.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'LinkList.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
The program '[6016] LinkList.exe' has exited with code 0 (0x0).

Code:

#pragma once
class Node
{
public:
    Node(int);
    int data;
    Node *next;
    ~Node();
};

#include "stdafx.h"
#include "Node.h"


Node::Node(int d)
{
    data = d;
    next = NULL;
}

Node::~Node()
{
}

#pragma once
#include "Node.h"

class LinkedList
{
    Node *head;
    Node *end;
public:
    LinkedList();
    void appendAtEnd(int);
    void deleteNode(int);
    void printList();
    ~LinkedList();
};

#include "stdafx.h"
#include "LinkedList.h"
#include <iostream>

using namespace std;

LinkedList::LinkedList()
{
    head = 0;
    end = head;
}

void LinkedList::appendAtEnd(int d){
    Node* newNode = new Node(d);
    if (head == 0){
        head = newNode;
        end = newNode;
    }
    else{
        end->next = newNode;
        end = end->next;
    }
}

void LinkedList::deleteNode( int d){
    Node *tmp = head;
    if (tmp == 0){
        cout << "List is empty!\n";
    }

    while (tmp->next != 0){
        if (tmp->data == d){
            tmp = tmp->next;
        }
        tmp = tmp->next;
    }
}

void LinkedList::printList(){
    Node *tmp = head;
    if (tmp == 0){
        cout << "List is empty!\n";
    }
    if (tmp->next == 0){
        cout << tmp->data << endl;
    }   
    while (tmp != 0){
        cout << tmp->data << endl;
        tmp = tmp->next;
    }


}
LinkedList::~LinkedList()
{
}

#include "stdafx.h"
#include "LinkedList.h"

int _tmain(int argc, _TCHAR* argv[])
{
    LinkedList list;
    list.appendAtEnd(1);
    list.appendAtEnd(2);
    list.printList();

}
AirSlim
  • 13
  • 3

1 Answers1

0

The list should be printed in the console (not in debug output window), but the console is closed too quickly, so you don't see it. There's no code to wait for some input from the user. Add something like this at the end of the main function:

int _tmain(int argc, _TCHAR* argv[])
{
    ...
    cout << "Press Enter...";
    cin.get();
}
Dialecticus
  • 16,400
  • 7
  • 43
  • 103
  • Thank you! I also found this solution that worked for me: http://stackoverflow.com/questions/8412851/visual-studio-2010-cannot-find-or-open-the-pdb-file – AirSlim Apr 02 '14 at 00:26