Solved

What is wrong here?

Posted on 2008-06-15
2
175 Views
Last Modified: 2010-04-21
I get no compile errors I get a weird output for x

Here is my code:


#include <iostream>
 

using namespace std;
 

int main()

{

	struct Point

	{

		int x;

		int y;

		Point *next;

	};
 

	Point *first, *last, *newNode;

	int num;

	int count = 0;
 

	first = NULL;

	last = NULL;
 

	cout << "Enter how many integers to enter: ";

	cin >> count;

	cout << endl;
 

	for (int i = 0; i < count; i++)

	{

		cout << "Enter for X: ";

		cin >> num;

		cout << endl;
 

		newNode = new Point;

		newNode->x = num;
 

		cout << "Enter for Y: ";

		cin >> num;

		cout << endl;

		

		newNode = new Point;

		newNode->y = num;
 

		newNode->next = NULL;
 

		if(first == NULL)

		{

			first = newNode;

			last = newNode;

		}

		else

		{	

			last->next = newNode;

			last = newNode;

		}

	}
 

	cout << "Linked List in the order entered: ";

	

	for (int i = 0; i < count; i++)

	{

		cout << first->x << " ";

		cout << first->y << endl;

		first = first->next;

	}
 

	cout << endl;
 

}

Open in new window

0
Comment
Question by:jschmuff
2 Comments
 
LVL 4

Accepted Solution

by:
zveljkovic earned 500 total points
ID: 21790119
Hi. I wanted to post on your deleted topic too :)
Error is in line 38
you should delete it.
0
 

Author Closing Comment

by:jschmuff
ID: 31467432
Thanks man, your awesome. I couldn't figure out what was wrong here.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java constructor error 8 101
WPF - Tooltips for ComboBox items 5 36
Problem to error 4 45
Interview question Javascript, database 12 31
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now