kevinkace 0 Newbie Poster

You are a champ, thanks so much!

Now I just need to fix my logic and I'll be home free. Thanks again!

kevinkace 0 Newbie Poster

ie6 does not support repeating trans pngs. If you have a script to bypass this, then perhaps paste here what it is.

kevinkace 0 Newbie Poster

There's something wrong with my push function, or how I'm initializing the linked list. Can anyone tell why?

The pointer 'operands' wont point to the new head, and always points to the first node created. Adding a second node appears to partially work, (second node->next points to the first node, first node->prev points to the second node). But after exiting the push function, 'operands' still points to the first node, which is now the last node...

NodeOperand* operands = new NodeOperand; // Linked list for operands
InitOperand(operands); // Initialize operands

pushDigit('4', operands); // works fine
pushDigit('2', operands); // adds second node, to the front of existing node, but operands still points to the node 4, and not the new head
pushDigit('9', operands); // Seems to basically replace the node 2, with operands still pointing to node 4
void InitOperand(NodeOperand* operand)
{
	// Desc
	cout << "Init... ";
	//operand = new NodeOperand;
	operand->data = 0;
	operand->next = operand;
	operand->prev = operand;
	
	cout << "done" << endl;
}
void pushDigit(char digit, NodeOperand* operands)
{
	if(isemptyOperands(operands))
	{
		operands->data = int(digit-48);
		operands->next = 0;
		operands->prev = 0;
	}
	else
	{
		/*NodeOperand* newNode = new NodeOperand;
		newNode->data = int(digit-48);
		newNode->next = operands;
		newNode->prev = 0;
		operands->prev = newNode;
		operands = newNode;*/
		NodeOperand* temp = operands;
		operands = new NodeOperand;
		operands->next = temp;
		temp->prev = operands;
		operands->prev = 0;
		operands->data = int(digit-48);

	}
	return;
}
kevinkace 0 Newbie Poster

Having a hard time finding a way to do this

Site is a fixed width centered with margin: 0 auto;. Now when the browser is large enough to display the full site width, the site is centered. If the browser is (resized) smaller than the site width, the left margin (auto) shrinks until gone, but the site content stays fixed at the upper left corner.

All's well until I try this: There's the main content background, but there's also another div with a second BG image based on the site section. I want it overlapping the right side of the main BG image, and fill farther to the right than the main BG - when the browser is big enough.

I can get that all above to work (position: absolute; left: 50%; margin-left: XXpx;) but if the browser width is less than the site container width, the secondary BG image starts to move to the left (based on the left:50%).

Is there a way to have this work?!

kevinkace 0 Newbie Poster

I was using

delete node->per->address;

which didn't work.

I think it has to do with the way I allocate memory for the person struct. I'll play around with it and post back my results.

kevinkace 0 Newbie Poster

any ideas?

kevinkace 0 Newbie Poster

it's similar to using multiple if/else statements but is more efficient when the value you are checking has only one option, ie making a selection from a menu.

Check this

// Enumeration for menu selection
enum Menu {
	ADDTOEND = '1',
	ADDTOSTART = '2',
	ADDSPECIFIC = '3',
	REMOVESPECIFIC = '4',
	PRINTLIST = '5',
	QUIT = '9',
};


int menuSelection = 0;

	while(menuSelection != QUIT)
	{
		menuSelection = SelectMenuChoice();


		switch(menuSelection)
		{
		case ADDTOEND:
			AddToEnd(userList);
			break;
		case ADDTOSTART:
			AddToStart(userList);
			break;
		case ADDSPECIFIC:
			AddSpecific(userList);
			break;
		case REMOVESPECIFIC:
			if(userList->head != 0)
			{ RemoveSpecific(userList); }
			else
			{ cout << "No nodes to delete" << endl; }
			break;
		case PRINTLIST:
			PrintList(userList);
			break;
		default:
			break;

		}
	}
kevinkace 0 Newbie Poster

how about a for loop?

for (int i=0; i<it; i++)
{
	cout << "<";
} cout << endl;
kevinkace 0 Newbie Poster
case 1:
	int newValue == fun2(number1, number2);
	break;
kevinkace 0 Newbie Poster

Thanks a lot for the replies.

This is for a course "Foundations of C", but is a preperatory course for a C++ course. Using new/delete is definitely how it's explained in the course material. I think the idea is to make programs in valid C++, but not using OOP.

I put how I called DeleteNode in the original post, but again:

DeleteNode(node);
delete node;

I tried delete [] node->per->address; but got an error.

kevinkace 0 Newbie Poster

Can't figure out what's wrong with my delete function. If I remove the delete for the name and address it works as expected, but am I not leaking memory that way?

Structs:

struct Person
{
    char* name;
    char* address;
    int zipcode;
};

struct Node
{
	Person* per;        // Person structure from earlier problem
	Node*  prev;        // address of the Node previous to this one
	Node*  next;        // address of the Node after this one
};
struct NodeList
{
	Node* head;
	Node* tail;
	int size;
};

Init a Node:

Node * newNode = new Node;
Init(newNode);
void InitNode(Node * node)
{
	// Declare and initialize new Person
	Person * tempPerson = new Person;
	
	// prompt user for new Person
	cout << "NEW NODE" << endl;

	_flushall(); // Cant get anything other than this to work
	ClearInputStream(); //Portable input clear (but doesn't work)

	char buffer[80+1]; // Initialize Char buffer for Person Name
	cout << "Name: ";
	cin.getline(buffer, 80);
	tempPerson->name = new char[strlen(buffer)+1]; // Assign memory for new Name
	strcpy(tempPerson->name, buffer); // Update name


	_flushall();
	ClearInputStream();

	char buffer2[80+1]; // Initialize Char buffer for Person Address
	cout << "Address: ";
	cin.getline(buffer2, 80);
	tempPerson->address = new char[strlen(buffer)+1]; // Assign memory for new Address
	strcpy(tempPerson->address, buffer2); // Update address

	int zip; // Declare Int for zip code
	cout << "Zip: ";
	cin >> zip;
	tempPerson->zipcode = zip; // Update zipcode

	node->per = tempPerson; // Update Person for Node

	return;
}

Deleting a node

DeleteNode(node);
delete node;
void DeleteNode(Node * node) …