#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
void StrConcat(char S[], char T[], char ST[])
{
int i = 0, j = 0, k = 0;
while (S[i])
ST[k++] = S[i++];
while (T[j])
ST[k++] = T[j++];
ST[k] = '\0';
return;
}
int StrLen(char S[])
{
int i = 0;
while (S[i])
i++;
return i;
}
void StrCopy(char S[], char T[])
{
int i = 0;
while (T[i]){
S[i] = T[i];
++i;
}
S[i] = '\0';
return;
}
bool StrEmpty(char S[])
{
if (!S[0])
return true;
else
return false;
}
void StrDestroy(char S[])
{
delete S;
}
bool SubString(char Sub[], char S[], int pos, int len)
{
int slen = StrLen(S); int i;
if (pos<1 || pos>slen)
return false;
if (len<0 || len>slen - pos + 1)
return false;
for (i = 0; i < len; i++)
Sub[i] = S[pos-1+i];
Sub[i] = '\0';
return true;
}
int StrIndex(char S[], char T[], int pos)
{
int i = pos - 1; int j = 0;
while (S[i] && T[j])
{
if (S[i] == T[j])
{
i++; j++;
}
else
{
i = i - j + 1; j = 0;
}
}
if (j== StrLen(T))
return i-j+1;
else
return 0;
}
int main(void)
{
char S[20] = "zhangsanfeng";
char T[5] = "san";
char ST[30];
char T1[5];
cout << StrLen(S)<<endl;
StrConcat(S, T, ST);
cout << ST << endl;
StrCopy(T1, T);
cout << T1 << endl;
int i = StrIndex(S, T, 7);
cout << i << endl;
return (0);
}