📄 mystring1.cpp
字号:
// MyString1.cpp: implementation of the MyString class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SmartC.h"
#include "MyString1.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*MyString::MyString()
{
front=NULL;
current=NULL;
rear=NULL;
line_no=0;
}
MyString::~MyString()
{
Node* temp;
current=front;
while(current)
{
temp=current;
current=current->next;
delete temp;
}
front=NULL;
rear=NULL;
line_no=0;
}
void MyString::del()
{
Node* temp;
current=front;
while(current)
{
temp=current;
current=current->next;
delete temp;
}
front=NULL;
rear=NULL;
line_no=0;
}
void MyString::insert(char *pch)
{
int len=strlen(pch);
char* p= new char [len+1];
strcpy(p,pch);
Node* node=new Node;
node->pchar=p;
node->next=NULL;
if(front==NULL)
{
front=node;
rear=node;
current=node;
line_no++;
}
else
{
rear->next=node;
rear=rear->next;
line_no++;
}
}
Node* MyString::getnext()
{
Node* temp;
temp=current;
if(current)
current=current->next;
return temp;
}
int MyString::getline_no()
{
return line_no;
}
void MyString::reset()
{
current=front;
}*/
////////my fuction
void insertline(Node* node,int* linenum,char* string)
{
int len=strlen(string);
Node* temp=node;
while(temp->next)
{
temp=temp->next;
}
temp->next=new Node;
temp->next->next=NULL;
temp->next->pchar=new char[len+1];
strcpy(temp->next->pchar,string);
*linenum+=1;
}
void freenode(Node* node,int* linenum)
{
Node* temp;
while(node->next)
{
temp=node->next;
node->next=node->next->next;
delete [] temp->pchar;
delete temp;
}
*linenum=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -