Visual C++ :: Doubly Linked List And Basic Text Editor

Sep 23, 2014

I'm supposed to make a basic text editor using a doubly linked list, I have pretty much written most of it but keep coming across several problems. In certain places,all marked in the code, I get the error "expected a declaration" ive looked online and nothing ive found works. And secondly I also get the error" declaration has no storage class or type specifier" but i havent been able to find anything that works either.

Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <assert.h>
#include <string>

[Code] ....

View 6 Replies


ADVERTISEMENT

C/C++ :: Linked List To Simulate Text Editor

Mar 10, 2015

I am trying to make a text editor in C++ that uses Linked Lists as the main driving force. I need to make a program that can add a line of text at a certain point, delete a certain line of text, print the entire text, and quit and save the text to the original text file inputted from the shell script. My problems are with the cpp file, and the linked list files. My remove function is not what I need it to be I know that. I also know that there are some problems with my cpp file myEditor. My code is below.

#include <sstream>
#include "linkylist.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[]) {
//node* head = new node;

[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++ :: Doubly Linked List Polynomials

Apr 5, 2014

namespace main_savitch_5 {
class polynode {
public:

// CONSTRUCTOR: Creates a node containing a specified initial coefficient (init_coef), initial exponent (init_exponent), and initial links forward and backward (init_fore and init_back).

polynode(
double init_coef = 0.0,
unsigned int init_exponent = 0,
polynode* init_fore = nullptr,

[Code] ....

View 1 Replies View Related

C++ :: Traversing Doubly Linked List

Feb 26, 2014

I have no problem traversing at both forward and backward but not simultaneously. I can traverse forward, and traverse again forward with no problem. I can also traverse backward and traverse backward again with no problem (take note this is by not exiting the program). Without exiting the program, with the same datas inputed, if i traversed forward, i cannot traverse backward (it only gives me infinite loop of the first data) and vice versa.

#include <iostream>
using namespace std;
struct Node {
int data;
Node *next;
Node *prev;

[Code] ....

View 2 Replies View Related

C++ :: Doubly Linked List Reverse

Sep 13, 2013

my code is

#include<stdio.h>
struct node {
int info;
struct node *next, *prev;
};
typedef struct node *nodeptr;

[Code] ....

I have reversed a linked list it is reversing but additional two elements 0,0 are coming, whats going wrong....

View 1 Replies View Related

Visual C++ :: Making A Text Editor

Oct 24, 2013

when making a text editor do you have to create a parser for it or are parsers just used in compilers and interpreters?

View 6 Replies View Related

C :: Reversal Of Doubly Linked List Using Recursion

Mar 6, 2015

I am trying to reverse a Linked list using recursion but whenever I try to print it after reversal it prints only the last element of the list.

Code:
void reverseRecursive(Node **root, Node *temp)
{
Node *next = temp->next;
if(temp->next == NULL)
{
*root = temp;

[Code]...

I have just posted the reverse function to enable easy readability rather than post the entire code

View 7 Replies View Related

C :: Adding A Second Node To A Doubly Linked List

Mar 6, 2015

I am having trouble adding a second node to a doubly linked list. I define my list as follows:

Code:

typedef struct Node {
char command[256];
int length;
struct Node *prev;
struct Node *next;
} userInput;
}

[code]...

Now, when I iterate back through my list (I want to start at the tail and work my way towards the head), I can only ever get the 1st node to print, then the 2nd node is garbage, which means, to me, that I've linked something wrong.

View 3 Replies View Related

C :: Program To Manipulate Doubly Linked List

Nov 17, 2013

I'm trying to write a program that manipulates a doubly linked list. My professor wants it to have two structs, one called Node (containing the data, and pointers to the next and previous nodes) and one called DLList, which contains the nodes for the head and tail (which is then passed to all of my functions).

I'm a little confused how to access the head and tail, for instance, if I want to initially set them to null in the main function (he emphasized the need for this), or to use them in my functions. I've tried a lot of variations to call the head and tail, but I keep getting told that head and tail are undeclared in the function.

How might I access my head and tail, for instance in a main function, when they're defined like this? (I took out all of the logic in my functions for clarity)

View 1 Replies View Related

C++ :: Deleting Nth Node From Doubly Linked List

Sep 19, 2013

I need to delete the Nth node from a doubly linked list. I know I just cant delete it out right. I have all the goodies including a templetized node class. This is the code we're given:

template <typename T>
void doublyLinkedList<T>::deleteKthElement(const int item) {
}

It accepts an int, and should go to the Nth node and delete it.

View 1 Replies View Related

C++ :: Doubly Linked List With Head Node

Oct 17, 2014

i am trying to develop a doubly linked list class. I became stuck at a few of the functions as well as the main.cpp file. i have to insert a character sentence "TRICK OR TREAT" spaces included. I am stuck on the display and the listsize functions and im unsure if my insert has the head node in it. The function parameters were given to us and most of this code was given from a single linked list.

//node.h
#pragma once
class Node
{
publi

[Code].....

View 1 Replies View Related

C++ :: Circular Doubly Linked List Code

Feb 27, 2014

When I run this in main it gives me a windows error message. I believe it has something to do with my insertAtEnd function but I've gone over it a million times....

#include<iostream>
#include<string>
#include<vector>
#include"RhymeGame.h"
using namespace std;
Game::Game() {
head = NULL;

[Code] ....

View 3 Replies View Related

C++ :: Doubly Linked List Header File?

Jul 7, 2013

I'm not sure why my destructor isn't working..

typedef struct Node;
struct Node {
char data;

[Code]....

View 4 Replies View Related

C++ :: Pointer To Last Node Of A Doubly Linked List

Nov 30, 2014

Why is it sufficient to only have a pointer to the last node of a doubly linked list?

View 1 Replies View Related

C++ :: Notepad Using Two-Dimensional Doubly Linked List

Dec 19, 2013

Create a notepad that allows the user to write text on the console. For this purpose, the user should be able to control and track the movement of the cursor. The user can access, add and delete any part of the text. To add or delete a text, the user can take the cursor to that location (using the arrow keys) and perform the required operation. The working of the program (i.e. the movement of the cursor, add and delete operation) must be consistent with the working of the real notepad. However, you do not have to handle word wrapping.

In addition, the user should be able to save and load the data in a text file using S and L respectively. The program will automatically save the data in file save.txt, and load the data from the same file. There is no need to ask the user for the file name. Use Q to quit the notepad. Don’t forget to implement the destructor.

Internally, the notepad is composed of two-dimensional doubly linkedlist. Its implementation is just like a doubly linked list with an additional property that it can grow in two dimensions. Since text can be written on multi lines, each row of the 2D-linkedlist represents one line. Each node contains four links which it uses to connect to node before, after, below and above it. In addition each node can store a character.

View 9 Replies View Related

C++ :: Doubly-Linked List And Referencing Errors?

Oct 4, 2014

We had to convert a single-line text editor which uses arrays to one that uses OOP and double-linked lists and I have been doing it in steps. I have, for the sake of convenience, put my headers, implementation and main all in one file.

I'm compiling this program in Hercules (the getch function uses C code).

I keep getting the error from the compiler saying "Undefined Symbol" for functions:

insertNode(char, Node);
deleteNode(Node*);
insertHead(char);

The full message is: ld: fatal: Symbol Referencing Errors. No output written to a.out collect2: ld returned with 1 exit status.

// A fake single line text editor program.
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <termios.h>
//#include "main.h"
typedef char Letter;

[code]....

View 3 Replies View Related

C++ :: Adding To The End Of A Doubly Linked Circular List?

Dec 2, 2014

Should my if statement be

if (tail== NULL) or if(tail->next == tail) ?

View 4 Replies View Related

C/C++ :: Reversing A Circular Doubly Linked List

Apr 25, 2015

I print the original list, then reverse it, then try to print it again. Here is what I get when I do that:

So that second line should print 2 1 4 5

Here is the reverse function:

void reverseCirListDeque(struct cirListDeque *q)
{
struct DLink *curr = q->Sentinel;
do{

[Code].....

View 2 Replies View Related

C++ :: Swapping Nodes In Doubly Linked List?

Nov 15, 2014

I've been working on this linked list priority queue . I know that the root of the problem is in my swapUp() function (swapping the positioning of two nodes based on their priority), because the list works great up until it is called. The seg fault is not actually being caused by swapUp(), it's being caused by peekAt(), which returns the element in the node at position n. But the error does not occur unless swapUp() is called first, so that is where the issue is (I think).

There is also a seg fault being caused in the destructor, which I believe may have the same root cause in swapUp().

PRIORITY QUEUE:

#ifndef JMF_PriorityQueue
#define JMF_PriorityQueue
#include <iostream>
#include <string>
template <typename T>
class PriorityQueue{

[Code] .....

Okay, so I've tried implementing SwapUp() in a different new way, but it's still giving me the same problem

template <typename T>
void PriorityQueue<T>::swapUp(Node * target){
Node * partner = target->next; //Partner = target next

[Code] .....

This is such an elementary logic problem I don't know why I'm having so much trouble with it.

View 4 Replies View Related

C++ :: Traversing Both Ways In A Doubly Linked List?

Mar 22, 2015

I've been working on a doubly linked list project for my Data Structures course. I've got everything to work so far, except for traversing in both directions. Traversing in the forward direction works fine, but when I try choosing to traverse backwards (starting from the tail of the linked list), it just says that the value is not in the list. That being said, the output looks like this:

This is not true, as you can obviously see, the value 26 is in the list, just two elements to the left of the tail (the value in tail for this particular case, obviously, is 36). The output should have been something like, "The value 26 was found 2 elements from the tail node". Here's the code for the findValue() function:

Code:
template <typename T>
bool LinkedListX<T>::findValue()//bool valueFound {
int traverseDirection = 0;
bool found = false;
int key;

[code]....

View 6 Replies View Related

C :: Creating Temp Node For Doubly Linked List

Jan 28, 2015

Code:

#include <stdlib.h>
#include <stdio.h>
typedef struct characterNode {
char c;
characterNode *prev;
characterNode *next;
} CharacterNode;

[Code]...

What's wrong with this? People told me that casting malloc was bad, but I don't understand what struct cn *temp is doing.

Also, could I create something like:

Code: typedef CharacterNode *CharacterNodePtr To be a pointer to my struct type? Why would that be beneficial?

View 1 Replies View Related

C++ :: Move Node To Front Of Doubly Linked List?

Oct 10, 2013

I have to write a method that moves a node to the front of one. Here is what I have:

template<typename T>
void DoublyLinkedList<T>::moveToFront(ListNode<T>* n)
{

[Code].....

I've walked through it a few times, and I feel like this correct. However, my program's output is off and I'm guessing this function is the culprit. I think I just need a different pair of eyes to take a look at it.

View 2 Replies View Related

C++ ::  Find Duplicates Before Inserting Into Doubly Linked List

Mar 8, 2013

I have a text file that needs to be read by command line arguments. The text are all numbers and can have multiple numbers on one line separated by a space. I cannot use an array or sort the numbers.So say I have a text file, listNums.txt:

12
473 8 29
30 1
8
248 17 55
29 84
5

Basically I need to read one number, find out if its odd or even by dividing by 2, search the odd or even doubly linked list that it would go into to see if its in there, if its not then add it to the bottom of the list.

View 2 Replies View Related

C++ :: Creating Custom Templated Doubly Linked List

Feb 20, 2013

I need to create a templated doubly linked list, with an iterator class within the list class. This program is to function just like the STL list class but I only need to implement functions that I am using, My trouble is I am kind of clueless on the iterator part and the fact that the list is templated is giving me syntax grief. I have pasted the code I have done so far.

1. On the syntax implementing the list and iterator functions outside of the class
2. I am not sure when to deference the iterator in the functions, but think I have it right so far
3. For the reverse function can I copy the list into a new list in reverse then re add them to the original list overwriting the same values? I have the code I have so far there
4. For the iterator erase function, I am not sure if I am deleting the node correctly.
5. I am not sure if I need template <typename T> above the iterator functions. Does the iterator class need to be a template? Right now it is not.

// Templated doubly linked list class

#include <iostream>
using namespace std;
template <typename T>
class list {
private:
Node *head;
Node *tail;

[Code] ....

View 7 Replies View Related

C/C++ :: Add Function To Tail Of A Doubly Linked Circular List

Nov 30, 2014

I have a function that I would like to add to tail. It is not correct.

template<class T>
void DoublyLinkedCircularList<T> :: addToTail(T element) {
DoublyLinkedNode<T>* head;
DoublyLinkedNode<T>* temp;
temp->element = element;

[Code] .....

How do I fix it?

View 14 Replies View Related







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