473,414 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Need help with Pointers

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
2 1011
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tommy Lang | last post by:
I am working on this project and I need some help/pointers/comments to get me started, I am stuck. The program will be used to store information in an array while it is running. I need to store...
9
by: Simon | last post by:
Hi, if I have a structure like... struct sMyPointers{ ClassA *m_pPointerA; ClassB *m_pPointerB; void *m_pPointerToSomethingElse; };
9
by: kupiko | last post by:
Please can anyone help me on this code? I want to write all odd numbers in range from a to b but it doesn't work at all cases mainly when a is higher than b and when i type in negative numbers. ...
0
by: rokuingh | last post by:
ok, so i've been working on this one for quite a while, and the code is very big so i'm just going to give the relevant parts. this is a program that builds polymers (chemical structures of repeated...
1
by: ArcInversion | last post by:
Hi, I've been using a javascript script to create a dragon that flies across the page. Anyways, I'd like to make it so when you click the dragon it takes you to a new page. Was wondering if anyone...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
5
by: Y2J | last post by:
I am working through this book on C++ programming, the author is speaking of using linked lists. He gave and example which I found confusing to say the least. So I rewrote the example in a way that...
20
by: Martin Jørgensen | last post by:
Hi, I'm reading a number of double values from a file. It's a 2D-array: 1 2 3 4 5 6 7 ------------- 1 3.2 2 0 2.1 3 9.3 4
7
by: DDP3000 | last post by:
void F(int **A, int N) { int i,j; for(i=0;i<N;i++) for(j=0;j<N;j++) A=((i+j)%2==0)?1:-1; } I have never used such a thing before, so it might be a really stupid question but I cannot find...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.