By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,897 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,897 IT Pros & Developers. It's quick & easy.

Need help with Pointers

P: n/a
I am getting an error from my Print() function. It has something to do
with the way I'm trying to output the data from my pointer. Any help
would be greatly appreciated. Here is the code:
void SortedType::Print()
{
ofstream outFile;
outFile.open("out.data");

currentPos = listData;

if(listData != NULL) // ADDED LOOP
{
while(currentPos != NULL)
{
outFile << currentPos->info << " ";
currentPos = currentPos->next;
}
}
else
{
outFile << "Linked list is empty, No delete!";
}
}

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
js*******@gmail.com wrote:
I am getting an error from my Print() function.
What error?
It has something to do
with the way I'm trying to output the data from my pointer.
No joke. What's the data you're trying to output?
Any help
would be greatly appreciated. Here is the code:
void SortedType::Print()
{
ofstream outFile;
outFile.open("out.data");

currentPos = listData;
What's "currentPos"? What's "listData"?

if(listData != NULL) // ADDED LOOP
{
while(currentPos != NULL)
{
outFile << currentPos->info << " ";
What's "info"?
currentPos = currentPos->next;
}
}
else
{
outFile << "Linked list is empty, No delete!";
}
}


How do you really expect us to help you without seeing how 'SortedType'
is defined?

V
Jul 23 '05 #2

P: n/a
Victor Bazarov wrote:


How do you really expect us to help you without seeing how 'SortedType'
is defined?


To the OP:
Besides to what Victor has told you:
What you posted looks like a typical way to output
a linked list. If something like that fails, the problem
is often not the output code, but the code that built
the linked list.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.