2014-04-01 61 views
1

我想實踐我的C++,我想開始創建一個簡單的鏈表。我在Visual Studio中這樣做,我很難嘗試調試這個小程序。當我運行程序我得到的是:試圖調試一個簡單的鏈表代碼

'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). 

代碼:

#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(); 

} 

回答

0

名單應在控制檯中印(在調試輸出窗口),但控制檯過於迅速關閉,所以你看不到它。沒有代碼可以等待用戶輸入。在main函數的末尾添加如下內容:

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    ... 
    cout << "Press Enter..."; 
    cin.get(); 
} 
+0

謝謝!我也發現這個解決方案,爲我工作:http://stackoverflow.com/questions/8412851/visual-studio-2010-cannot-find-or-open-the-pdb-file – AirSlim