Stackdump/Stack Trace

Relatively new to c++(so this code may seem idiotic), I have slowly been teaching myself to code using C++ since last year and I'm stumbling on linked lists. This is the output and error I get when I run the program--

Please enter the names of the students(Last Name, First Name) Telephone Number and Street Address 

      1 [sig] CS 2 Project 2 1068 open_stackdumpfile: Dumping stack trace to CS 2 Project 2.exe.stackdump


I'm fairly sure this means i'm accessing memory that isn't supposed to be accessed but seeing as there are no actual ERRORS in my code i'm sort of stumped on where to go next. I am attempting to define a structure with 3 fields string, int and pointer(which can point to a structure of its own kind) then I must create a dynamic linked list using the structure previously defined with at least 10 nodes.

This is written in Cygwin for Eclipse and is on a windows 7 64bit

Again there are no errors showing in my code, but when I try to compile I recieve the stackdump error and my code terminates before any user interaction.

Here is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/****INCLUDES****/

#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;

/****STRUCTURE DEFINITION****/

struct SlistElement
{
	string name;
	int teleNumber;
	string address;
	SlistElement *next;
};

/******FUNCTIONS********/

SlistElement *make_Node();
SlistElement *create();
void displaylist(SlistElement*);


/********MAIN*********/

int main()
{
	cout << "Please enter the names of the students(Last Name, First Name)"
			" Telephone Number and Street Address " << endl << endl;

	SlistElement *current = create();
	displaylist(current);

return 0;
}





SlistElement *create()
{
    SlistElement *head = make_Node();
    SlistElement *current = head;

    for (int i = 0; i < 10; i++)
    {
       current -> next = make_Node();
       current = current -> next;
    }

current -> next = NULL;
  return head;
}





SlistElement *make_Node()
{
	string name1 = 0;
	SlistElement *ptr1 = new SlistElement;
	getline(cin, ptr1 -> name);
	return ptr1;
}




void displaylist(SlistElement *current)
   {
    while (current != NULL)
     {
        cout << current -> name << endl;

        current = current -> next;
     }
    cout << "NULL";
   }
solved it, I was writing *ptr1, *ptr2 etc... instead of *pt

mods can close the thread
Topic archived. No new replies allowed.