What is wrong here?

Posted on 2008-06-15
Medium Priority
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;
			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

Question by:jschmuff

Accepted Solution

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.

Author Closing Comment

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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
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…

587 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