[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

What is wrong here?

Posted on 2008-06-15
2
Medium Priority
?
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
zveljkovic earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

650 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