473,744 Members | 2,260 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::Pri nt()
{
ofstream outFile;
outFile.open("o ut.data");

currentPos = listData;

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

Jul 23 '05 #1
2 1018
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::Pri nt()
{
ofstream outFile;
outFile.open("o ut.data");

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

if(listData != NULL) // ADDED LOOP
{
while(currentPo s != 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
1942
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 objects of my classes Person(superclass), Student(inherit Person), Teacher(inherit Person) in that array. The name will be the unique key. These classes are all working ok. I want to be able to add, remove, find etc. objects. To all of this, I...
9
2842
by: Simon | last post by:
Hi, if I have a structure like... struct sMyPointers{ ClassA *m_pPointerA; ClassB *m_pPointerB; void *m_pPointerToSomethingElse; };
9
1384
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. Here is the code and i would appreciate anybody helping me. THANKS. #include<stdio.h> #include<math.h> void odd(float x, float y);
0
2607
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 monomers) which are represented as doubly pointed noncomplete binary trees. There are three different types of monomers (hence the three different constructer calling functions) the first one is the "leaves" of the tree, the second adds length...
1
1784
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 could help me out here. Below is the complete script. <SCRIPT language="JavaScript1.2"> var cursorpath="http://i68.photobucket.com/albums/i9/worklog_halcyon/Misc/pet1_lohi_dog.png" if (document.layers)
23
2545
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
3371
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 I could better understand the concept, he was trying to convey to me. I ran my own example and it crashed and burn "what a surprise!" : (. I ran the authors example out of the book and quess what, it crashed also, : 0. I ran them both on my...
20
4644
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
1398
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 the answer.
0
8970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9486
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9344
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9214
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8218
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6763
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.