C++ :: Removing First Item From Single Linked List

Oct 10, 2013

My algorithm is not working

void remove_first() {
current_node = head_node;
node * temp_node = current_node;
current_node = current_node->get_next();
head_node->set_next(current_node);
delete temp_node;
temp_node = NULL;
}

View 2 Replies


ADVERTISEMENT

C :: Removing A String - Linked List

Feb 19, 2013

I'm trying to go search through my linked list for a passed string and if it matches, remove it...but obviously link everything back together properly. This is what I have so far but when i pass it to my display function, which is properly working, it goes into an endless loop

Code:
void llRemoveString(LinkedList** ll, char* string) {
LinkedList* newNode = (LinkedList*)malloc(sizeof(LinkedList));
newNode->value = string;
LinkedList* n = *ll;

[Code] ....

View 8 Replies View Related

C++ :: Removing Element From Template Linked List?

Nov 11, 2013

I have been trying to implement a way to remove a post from a list of posts implemented with a template doubly linked list. I have thought that the best way to do this might by operator overloading, but I have digressed. I have just thought of using a isEqual that checks equality, but when trying to implement i'm getting weird errors.

This is within my class wall, which is a linked list of wall posts, getPostInfo is within the class WallPost.

bool isEqual(WallPost const & a, WallPost const & b)
{
if(a.getPostInfo() == b.getPostInfo())
return true;
else
return false;
}

I have several instances of the error "void illegal with all types" on line 3. It also is complaining about a not being a arithmetic, unscoped enum, or pointer type. I am assuming that it is because my getPostInfo function is a void.

View 16 Replies View Related

C/C++ :: Linked List Insert Item Function

Oct 14, 2014

It is suppose to insert items in Linked List in sorted ascending order and no duplicates are allowed.The code complies but it creates duplicates out of order.

ListRetVal CSortedList :: InsertItem(const ListItemType &newItem)
{
ListItemNode* newLNode = new ListItemNode();
newLNode->value=newItem;
newLNode->next=NULL;

[Code].....

View 5 Replies View Related

C++ :: Process To Delete Everything From Single Linked List

Aug 23, 2013

what is the process to delete everything from a singly linked list. Like S= 1->2->3->... I want to remove all the values from S and reuse it again to store new datas.

View 2 Replies View Related

C :: Removing Item From A Queue

Aug 17, 2014

I'm having a problem with removing an item from a queue. At first in the debugger I got SIGTRAP but I don't get it anymore but the problem still exists. When you try to remove an item from the queue the first nothing happens. Here's the code below compile it and you see what I'm talking about.

Code:

#include <stdio.h>
#include <stdlib.h>
struct Node {
char let;
struct Node *nextNode;
};

[code]....

View 12 Replies View Related

C/C++ :: Print Single Linked List Backward With Functions / Classes - Error Message Regarding Header Files

Oct 11, 2014

I'm trying to print a single linked list backward with functions/classes. I have created the main file and 3 header files. But I'm getting an error on one of the header files, linkedListIterator after adding #include "linkedListType.h". It says that "linkedLlistType.h" is calling itself. And when I try to run it, I get an error of "too many header files." I have tried changing the headers many times, but nothing seems to work.

.cpp file:

/*(Printing a single linked list backward) Include the functions reversePrint and recursiveReversePrint, as discussed in this chapter, in the class linkedListType. Also, write a program function to print a (single) linked list backward. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.)*/

#include "linkedListType.h"
#include "orderedLinkedList.h"
#include "linkedListIterator.h"
#include <iostream>
using namespace std;
struct nodeType

[Code] ....

header files:
[URL] .... (error in this header file)
[URL] ....

View 9 Replies View Related

C++ :: Compare Single Value With A Value From Linked Lists

May 2, 2013

I'm trying to compare a single value with a value from my Linked list and if they are same, I want to add the value from the list to new list. In other words I want to create a new List with values with the first one. Here is the code that I made, but it's not working.

This is the code with which I search in the first list for a node with a value. In the main() function I have A.find_city(), so it can start from the start_pointer from the first list:

void List::find_city() {
List *temp1;
int b = 0;
char city[20];
cout << "Enter city: ";
cin >> city;
temp1 = start_ptr;

[Code] ....

This is the code with which I add a node to the new list:

void List::in(List *temp1) {
List *temp2;
if(start_ptr == NULL)
start_ptr = temp1;

[Code] ....

View 9 Replies View Related

C :: Library Database Using Single Linked Lists

Jan 4, 2015

Anyway, I have an assignment in which I'm supposed to create a program to be used in a library. Basically a database storing all books currently outside the library along with who and when borrowed them. It also says I should use single linked lists.

Now, I've got a general idea of how to make it work but I've stumbled upon a problem. Since the program has to write all the data put into the database in a file and be able to tell the user whether a book has been kept too long by the reader, I figured I'd implement the struct tm to convert the date when the book was borrowed (or rent, whatever, English is not my first language ;p) into UNIX time.

Then, when I'd like the program to tell me which books are being kept hostage by the readers the program would look for a certain record (like a string inside a certain struct) and compare the date inside that record with current date and then the result of this comparison would be compared with a given, defined time limit. Although this is all a different kinda function, it's a bit simplier, I guess, and I think I'll work it out. However to get there at all I need to be able to store the data correctly and there is a problem, which I'll explain on the other end of the code .Here is the code I came up with:

Code:
#include <stdio.h>#include <string.h>
#include <stdlib.h>
#include <time.h>
int DisplayMenu();
int ReturnToMenu();
int AddBooks(char *filename);

[Code] ....

So, my problem is as follows: the date seems to be stored alright, but it's wrong. For checking I had a Code: printf("%d", mktime(&date)"); added and it returned "-1"... As I said, I'm relatively new to coding/programming and my knowledge is rather rudimentary.

By the way: I had one more gremlin haunting me on this one. Namely at the begining of the input to the AddBooks function:

Code:
int flag = 0; do
{
printf("Please type in the book's title:
");
gets(newbook.title);
if (strcmp(newbook.title, "") == 0)

[Code] ....

The do while loop is to ensure 'unempty' input. Without this loop however, the program would display the message "Please type in the book's title:" but it wouldn't wait for input. It's simply jump to the next printf and wait for input then... I figured it might be becuase it took the 'Enter' that was somehow still in the memory after the user confirms his selection in the menu... It's just a guess, though.

View 1 Replies View Related

C# :: Get Item From List In Another Class

Jan 15, 2014

How can I get the items from a list into textboxes. I am doing an windows form application in visual studio.

I have the first form with a couple of textboxes.

I want the inputs be saved in a list. And then displayed in another form. How to move on. The class with the list looks like this:

public class Casecs {
public List<caseInformation> fallInformation = new List<caseInformation>();
public class caseInformation {
public string caseId { get; set; }
public string phoneNumber { get; set; }
public string description { get; set; }
}

Then the form with the inputs in textboxes looks like this:

Casecs Casecs = new Casecs();
Casecs.fallInformation.Add(new ERIS.Casecs.caseInformation {
caseId = txtCaseId.Text,
phoneNumber = txtPhonenumber.Text,
message = txtMessage.Text
});

Then where I am stuck a form with some textboxes where I want the list items to be displayed:

public partial class btnDispatch : Form {
public btnDispatch() { }
public btnDispatch(List<Casecs.caseInformation> fallInformation) {
InitializeComponent();

View 7 Replies View Related

C# :: Create A Button For Each Item In A List

Jan 26, 2014

Basically, the program is just sort of a soundboard. The way it is now, it just reads all the names of the files in a particular folder (all .wav files), and then adds an entry to a listBox for each file found. What I would like to do, is instead of a listBox, have buttons for each one. Is there any way to iterate through a list of items and create a button for each one? The main problem I see is placing the buttons. It would have to have some sort of grid to place them in I would imagine...

View 3 Replies View Related

C# :: Sharing Item List Object Between Two Forms

Nov 4, 2014

I've changed up my code to the retail checkout WFA I am trying to make. I have an item list filled with objects of the now globally accessible 'Item' class, but I'm having trouble.

Essentially, I want to send an object of the item class chosen from a dropdown menu to form2, where I will fill in certain blank attributes with data entered in form2's text boxes and comboboxes. The problem, it seems, is I need another itemlist in form2 that will hold the object being passed to form 2, so I can then pass all the information to textboxes on form3 (the receipt/review page). It's been more than a year since I coded with C#, and I've forgotten quite a bit. I was also not able to find any tutorials on building an item list without an associated combobox or droplist, which is what I need.

This is my item class (minus most of its properties so the page doesn't stretch).

class Item {
public string prodName;
public string fName;
public string lName;
public string ccNum;
public string ccProv;
public string shipAddr;

[code] ....

For anyone who didn't see my last question, I'm in a User Interface Design class, not a C# class. I know this probably isn't the best code out there, but for my purposes the program just needs to compile beginning to end and pass the data like it should.

View 1 Replies View Related

Visual C++ :: Get The Path For A Selected Item In A List Control?

Jan 29, 2013

How do I get the path for a selected item in a list control?

View 5 Replies View Related

C# :: Open WPF Window From Double Click On Selected Item In A List?

Apr 23, 2015

I have a list with 2 items in it. When I double click on item 1, I want to open Window1.xaml, when I double click on item 2, I want to open Window2.xaml...

The code below works for popping up a message box, or window for that matter. But I really need to get the Window1 and Window2 based on the clicking of the correct selected item in the list.

Here is some code:

<ListView d:DataContext="{d:DesignData }" Name="PharmacyLv" IsSynchronizedWithCurrentItem="True" l:Sortbehavior.CanUserSortColumns="true" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="MouseDoubleClick" Handler="ListViewItem_PharmDoubleClick" />
</Style>
</ListView.ItemContainerStyle>

[code].....

View 3 Replies View Related

C++ :: Colon Usage (single And Double) Member Initializer List?

Aug 27, 2013

The below code is taken from the open source 7zip project (7z920CPP7zipUIFileManagerBrowseDialog.h)

Code:
class CBrowseDialog: public NWindows::NControl::CModalDialog {

What does the single colon (CBrowseDialog:) mean? Is that Initializer List?

I know the double colon (NWindows::NControl::CModalDialog) is Scope Resolution Operator.

Why is (: public NWindows::NControl::CModalDialog) used with the class declaration?

Similar code is found through out the project along with class declarations.

View 2 Replies View Related

C++ :: Creating A Linked List Of Common Elements From Two Other Linked Lists

Apr 29, 2013

I'm trying to write a function that takes two linked lists and creates a third one with only the common elements.

It assumes the first list (the caller) has no dups, but it doesn't seem to be working. The program doesn't crash, it just hangs when it is supposed to display L3 (the third list)..everything else runs and is displayed fine.

template <typename T>
LList <T> LList <T>:: common (LList <T> &B)//common fct
{
Node <T> *hunter1 = Head;

[Code]......

View 10 Replies View Related

C :: Insert Linked List Into Another Linked List

Jun 29, 2013

I have a linked list comprised of chars like so...

Code:

node1 - "p"
node2 - "o"
node3 - "p"

I need a function that will take in three perameters...node *replaceChar(node *head, char key, char *str)Stipulations of this function. head is the head of the list, 'key' and 'str' are guaranteed to contain alphanumeric characters only (A-Z, a-z, and 0-9). str can range from 1 to 1023 characters (inclusively). So if I call this function with these perameters..

Code:

node *head == /*the head of the list to be examined*/
char key == "p"char *str == "dog"The new list will look like this...
node1 - 'd'
node2 - 'o'
node3 - 'g'
node4 - 'o'
node5 - 'd'
node6 - 'o'
node7 - 'g'

All instances of 'p' were replaced with 'dog' I have a toString function which takes in a string and converts it to a linked list and returns the head. So assume that you can call the function on str = "dog" so...

Code:

toString(str) == /*this will return the head to the list made from the str*/

If it's unclear what my question is...I am stumped on how to write the replaceChar function the one that takes in three perameters..

View 3 Replies View Related

C :: Linked List / Adding Element To Beginning Of List

Dec 31, 2014

Code:

// Write a function called insertEntry() to insert a new entry into a linked list.

Have the procedure take as arguments a pointer to the list entry to be inserted (of type struct entry as defined in this chapter), and a pointer to an element in the list after which the new entry is to be inserted.

// The function dveloped in exercise 2 only inserts an element after an existing element in the list, thereby prenting you from inserting a new entry at the front of the list.

(Hint: Think about setting up a special structure to point to the beginning of the list.)

#include <stdio.h
struct entry1 {
int value;
struct entry1 *next;
};

[code]...

This is a working version of the exercise, but I don't think I'm doing what's asked. I was able to add an element to the beginning of the list using an if statement, not creating a special structure that points to the beginning of the list. How would I go about creating a special structure that points to the beginning of the list to add a new element at the beginning of the list?

View 8 Replies View Related

Visual C++ :: Enable / Disable Menu Item 2 In OnUpdate Handler Of Menu Item 1?

Sep 15, 2014

I have two menu items. When item 1 is disabled, I want item 2 to be disabled as well. In the OnUpdate handler of menu item 1, I have tried to use "t_pMenu = pCmdUI->m_pMenu;", "t_pMenu = pCmdUI->m_pSubMenu;" and "t_pMenu = pCmdUI->m_pParentMenu;" but I always get NULL t_pMenu. How can I achieve this purpose?

Code:
void CDummyView::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
if(m_bShowMenuItem1) {
pCmdUI->Enable(TRUE);

[Code]....

View 14 Replies View Related

C++ :: Linked List Delete List?

May 30, 2013

I'm working on a linked list and was wondering how this looks to everybody else for a deleteList function.

void deleteList(Node* head)
{
Node* iterator = head;
while (iterator != 0)

[code].....

View 6 Replies View Related

C :: Doubly Linked List

May 15, 2013

I need to make the functions using these function prototypes. I am mainly having problems with GetFirst() and SwapData() but how to do it..

Header File with Prototypes
Code:
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
/**
* @file
* This file provided a doubly-linked list implementation capable of storing any arbitrary data.
* The list implementation relies on a chain metaphor: a list is merely a sequence of links
* (ListItems) and there is no separate construct to represent the entire list, each ListItem in it

[Code]....

View 14 Replies View Related

C :: Linked List Search

May 7, 2013

I read an article on linked list here: C Linked List Data Structure Explained with an Example C Program

Code:

struct test_struct* search_in_list(int val, struct test_struct **prev)
{
struct test_struct *ptr = head;
struct test_struct *tmp = NULL;
bool found = false;
}

[code].....

What is "if(prev)"? Wouldn't "prev" always have the same value? Secondly, if tmp is NULL (which will be the case when the loop if(ptr->val == val) finds a match the first time it is run), is *prev assigned a NULL?

View 1 Replies View Related

C :: Double Linked List

Jan 2, 2014

I'm having a small issue here with my linked list.I built a linked list with strings and it worked perfectly.Now since i'm using strtok() to separate the string.for now here's what i've got:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct dict_word *word;
typedef struct node *Node;
typedef struct double_linked_list *DLL;
}

[code]....

View 1 Replies View Related

C :: Static Linked List

Jan 6, 2014

I have the codes for the functions: "Given the functions that we have discussed and defined in the class and the code that we have created, create the code for the Delete Node function and the Search function. Create an application that will incorporate all the functions that we have discussed and the new ones that you need to create. The application should allow the linked list to be built initially from a text file. The application should then allow for the user select an operation to perform. The acceptable operations are

- to search for an item
- to delete an item
- to enter a new item
- to exit the application

After the initial build and loading of data from the textfile, the application should print a listing of each item in the list and the node that it is located in. after a delete or insert, the application should display an output of the list again showing each item in the list and the node that it resides in.

The data item for this problem will be the inventory structure that we created in class and the data is in the inventory file that you already have downloaded."

View 4 Replies View Related

C :: Singly Linked List

Mar 7, 2013

I am having difficulty getting my program to run. I have looked and looked many times trying to figure out what I am doing wrong. I have a hunch that it's my load function that's acting up, but from my perspective, my creation of my singly linked list looks good. From the creation of my singly linked list, does anything stand out as being abnormal?

Code:

typedef struct Node {
char word[LENGTH+1];
struct Node *Next;
} Node;
}

[code]....

View 6 Replies View Related

C :: Sorted Linked List

Apr 2, 2013

I been ask to create a sorted linked list module, and to test each function with 1 unit, 2 +.so i wrote my addtofront function( we have to use the same as the teacher)

Code:

struct MyList{
char * name;
Sorted * AddmyChar;
struct MyList * next;
}

[code]....

but i cant seem to test it because it always display a seg fault.... i dont know what i did wrong....how do i call this function in main to display a string i want?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved