Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C++
#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)//It is still to be Completed
{
	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);

	}

}
Posted
Updated 16-Aug-19 22:50pm
v3
Comments
OriginalGriff 3-Mar-18 4:41am    
What's the problem?
How can you tell it's a problem?
What do you do to generate it?
What have you done to find out why it's happening?

Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And "I'm having a problem" doesn't tell us anything about what is going on!

1 solution

Read the Virtual Key Codes Documentation and for the very important function GetKeyState of Microsoft carefully.

You better use the named constants or write some comment to your code for the later reader.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900