If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Welcome to Mac-Forums! Join us to comment and to customize your site experience! Members have access to different forum appearance options, and many more functions.

Hey everyone, this is my first time posting, so hopefully i won't commit some kind of egregious faux pas.

Anyways, I'm trying to create and read back a simple linked list in C++. So far, I think I've built it and filled it with 10 different arrays of characters of about 22 characters each. (They are simple questions written in english.) My program compiles fine, and it runs, but only to a certain point. When it gets to the following line:

...Now all this seems fine and good, but after this is done and I set 'head' equal to the function, and then ask it to print out 'head', it gives me this:

head= 0x7fff70464b00
head->link= 0x7fff704614a0
head->info = ?핂?

...The info here is really very weird, and it's obviously not equivalent to the array of characters "This is statement 1." I feel that this might be because I'm setting the 'head' wrong. I want it to be equal to the first node of the list, but I'm not sure if setting it equal to the function call that builds the entire list is the way to do that.

The way I have the program written, it's supposed to iterate over each item in the list and print out the info in each. (10 items in all). It [should] do this by first setting 'current = head', and then after each iteration setting 'current = current->link'.

For some reason, though, it only iterates two complete times, giving me garbled output each time, and then on the third time, it gives me a Segmentation fault instead of printing the info. It looks something like this:

... So anyone have any ideas? I apologize if this is too much information, but I wanted to be as thorough as possible without simply posting my code, (it's for a school assignment, and I wanted to keep everything on the "up and up"). That being said, if there's other information anyone needs to make a guess at what's going on, please just let me know.