my actual problem is with remove words also can anybody tell me the keys for shift right and shift left.
i have to do this thing so every help in building logic will be appreciable.
Thanks!
• When the user types a data input key such as an alphabet, number or symbol, a
textNode with the corresponding character is added immediately after the node
pointed to by the cursor and the cursor is moved one step forward.
• When the user presses the backspace key the node pointed to by the cursor is
removed and the cursor moves one step back.
• The user should be able to use the direction keys to move the cursor within the
text without editing the text. Note: vertical direction keys will move cursor within
lines.
• The user should be able to insert a new line wherever she wishes in text. Note
that a new line is nothing but a character as far as the text is concerned, but it is
displayed is a special way.
• Using the Shift + direction keys the user should be able to select the text. She
should be able to use Ctrl+X, Ctrl+C and Ctrl+V to cut, copy and paste segments
of text to any point of their choice within the text.
• User should be able to find Ctrl+F and replace Ctrl+R text. In this case a small
window (maybe near the bottom of the screen) should ask the user for the text to
be found and the new text to replace it.
•
[edit]Code block added - OriginalGriff[/edit]
What I have tried:
#include<iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
struct node{
char data;
node * next;
};
void addtolist(node *&head, node*&tail, char data, int &size,node* current)
{
if (tail == nullptr)
{
head = tail = new node;
head->data = data;
head->next = nullptr;
current = head;
}
else
{
tail->next = new node;
tail = tail->next;
tail->data = data;
tail->next = nullptr;
current = tail;
size++;
}
}
void printlist(node *head, int size, node *tail, node* current)
{
current = head;
while (current != nullptr)
{
cout << current->data;
current = current->next;
}
}
void remove(node*&head, node*&tail, node *& current){
node *prev = nullptr, *current1 = head;
while (current1 != nullptr && current1 != current)
{
prev = current1;
current1 = current1->next;
}
if (current1 == nullptr)
{
cout << "Key not found !";
}
else if (prev == nullptr)
{
head = head->next;
delete[]current1;
cout << "yes";
}
else
{
prev->next = current1->next;
delete[]current1;
cout << "yes";
}
}
int main()
{
int n, n1, n2, n3;
char w='a', w1, w2;
node * head = nullptr;
int size = 0;
node *tail = nullptr;
node *current = head;
while (w != 13)
{
w = _getch();
if (w <= 126 || w >= 32)
{
addtolist(head, tail, w, size,current);
}
else if(w == 8)
{
remove(head, tail, current);
}
Sleep(1500);
printlist(head, size, tail, current);
}
}