问题描述
- 为什么执行output()函数时会有乱码,但是把texteditor类去掉就好了?
- #include
#include
#include
using namespace std;
struct Node
{
char str[20];
Node *next;
}node;
class LinkList
{
public:
Node *head*tail;
public:
LinkList(){};
~LinkList(){};
void Input()
{
int tag=0;
Node *p*q;
head=new Node;
head->next=NULL;
q=head;
cout<<""请输入文章并输入#结束""< while(tag!=1)
{
q->str[20]='';
p=new Node;
for(int i=0;i {
p->str[i]=cin.get();
if(p->str[i]=='n')
break;
if(p->str[i]=='#')
{
tag=1;
p->str[i]='';
break;
}
}
p->str[18]='n';
q->next=p;
q=p;
}
q=NULL;
delete q;
}
void Output()
{
Node *q;
q=head->next;
while(q!=NULL)
{
cout<str;
q=q->next;
}
}
};
class TextEditor
{
public:
int cursor; //光标
int line; //行数
int offset;
int total;
string name; //文本名
public:
TextEditor(){};
~TextEditor(){};
string GetName()
{
cout< cout cin>>name;
return name;
}
void SetName()
{
cout< }
int GetCursor(LinkList article)
{
cout cin>>line;
cin>>offset;
Node*p;
char str1[20];
p=article.head;
for(int i=0;i {
p=p->next;
}
cout<str[offset];
return p->str[offset];
}};
int main()
{
TextEditor t;
LinkList L;
L.Input();
L.Output();
return 0;
}
时间: 2024-12-03 11:12:06