#include
#include
The class string
{public:
Void the show ()//show string
{
Cout
Int length length ()//o
{
return size;
}
String insert (char * s, int pos)//insert string
{
String temp;
Temp. Size=strlen (s) + the size;
for(int i=0; I
Temp. STR [I]=STR [I];
}
for(int j=0; J
Temp. STR [pos + j]=s [j];
}
For (int k=0; K
String replace (char * s, char * p, char * t)//string substitution
String: : size_type pos=0;
String: : size_type a=p. considering ();
String: : size_type b=t.s considering ();
While ((pos=s. ind (p, pos))!=the string: : npos)
S.e rase (pos, a);
S.i nsert (pos, t);
Pos +=b;
Void the Delete (char * ch [], int n)//Delete string
Int len=strlen (ch);//get the length of the string (built-in function in the # include
for(int i=0; I
Ch=ch [I - 1] [I];//to all the characters in the front of the n - 1 after the character after the replacement for the
Char * STR=ch;//STR copy ch
STR [len - 1]='\ 0';//the last one to end of the string flag, thus causing the memory leak, because there is a '/0'
Ch=new char [] len - 1;//a new settlement space
For (int I; I
The delete char * STR;//release space before
Int index (char * s, char * t)//string search
if (! S | |! T) return 1;
Char * p=STRSTR (s, t);
if (! P) return 1;
The return p - s;
Void Strcat (char * z)//the connection string
Char * a;
A=new char [strlen (z) + length].
Strcpy (a, STR);
Strcat (a, z);
STR=a;
Cout
{
While (a!=0)
{
Cout<& lt;" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "& lt;
The switch (a)
{
Case 0:
Case 1: cout<& lt;" Please input string: "& lt;
cin> S1.
break;
Case 2: cout<& lt;" The string you entered is: "& lt;
s1.show();
break;
Case 3:
Cout<& lt;" You for the length of the input string: "& lt;
Case 4:
Cout<& lt;" Please enter the insert position: ";
Int pos.
cin> Pos.
Cout<& lt;" Input you want to insert a string: ";
Char * s2=nem char;
cin> S2.
String s1=s1. Insert (st2. Pos);
Cout<& lt;" The new string is: ";
s1.show();
break;
Case 5:
Cout<& lt;" Please enter the alternative content: ";
Char * s4=new char;
cin> S4.
Cout<& lt;" Please input the replacement parts: ";
Char * s5=nem char;
cin> S5.
String s1=replace (s1, s5, s4);
Cout<& lt;" The new string is: ";
s1.show();
break;
Case 6:
Cout<& lt;" Please enter the characters you want to delete: ";
cin> a;
String s1=delete (s1, a);
Cout<& lt;" The new string is: ";
s1.show();
break;
Case 7:
Cout<& lt;" Please enter a string to find: ";
Char * s5=new char;
cin> S5.
String s1=index (s1, s5);
Cout<& lt;" The new string is: ";
s1.show();
break;
Case 8:
Cout<& lt;" Please enter another string: ";
Char * s6=new char;
cin> S6.
S1=strcat (s1 and s6);
Cout<& lt;" Connection string: ";
s1.show();
break;
Default: cout<& lt;" Error! Please enter the correct number!"
};
return 0;
}
Error: 233. CPP
D: \ vc + + \ MyProjects \ 123\233. CPP (135) : error C2958: the left parenthesis' (' found at 'D: \ vc + + \ MyProjects \ 123\233. CPP (27)' was not matched correctly
D: \ vc + + \ MyProjects \ 123\233. CPP (139) : fatal error C1075: the end of the file found before the left brace '{' at' D: \ vc + + \ MyProjects \ 123\233. CPP (15) 'was matched
An error occurred when performing cl. Exe.
CodePudding user response:
According to this format, the menu a single function displays# include "stdafx. H"
# include "List. H"
#include
#include
using namespace std;
Int Menu ()
{
int num;
cout <"* * * * * * * * * * * * * * * * * * * *" & lt;
return num;
}
Int _tmain (int arg c, _TCHAR * argv [])
{
The List mylist.
Mylist. Readfile ();
Int num=Menu ();
Bool flags=1;
While (flags)
{switch (num)
{
Case 1: mylist. The Add (); break;
Case 2: mylist. Del (); break;
Case 3: mylist. The Search (); break;
Case 4: mylist Showfile (); break;
Case 5: cout & lt;