[英]Linked list for text editor in c++
我试着用c ++编写一个文本编辑器。 每行文本都必须进入链表的节点。 我已经完成了链表的必备,我现在需要的是如何将每行文本放入每个节点。 这就是我的问题,如何将每行文本放入每个节点。
这是我的代码:
typedef int ListItemType;
typedef Strac Node* NodePtr;
Struc Node
{
ListItemType data;
NodePtr next;
};
int main()
{
//Create empty list
NodePtr head = NULL;
//1st node
head = new Node;
//Initialize the field
head -> data = ?;
head -> next = NULL;
//2nd node
head -> next = new Node;
//Initialize the field
head -> next -> data = ?;
head -> next -> next = NULL;
}
我猜每行文字都在问号所在的位置?
谢谢
文本编辑器通常使用Rope数据结构支持其编辑缓冲区
此外,C ++中有一个标准的双向链表数据结构,称为std :: list。
如果你想表示一行文本,也许你应该使用std :: string:
typedef std::string ListItemType;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.