串链接中的问题
自认为编程技术还行,在做两个串链接时出现问题了,在此求助各位大大!使用vc++
头文件stringconnet.h
#include <iostream.h>
#define TURE 1
#define FALSE 0
#define OVERFLOW -1
#define MAXSTRLEN 255
typedef char ElemType;
typedef int Status;
typedef unsigned char SString[MAXSTRLEN+1];
Status connet(SString &T,SString S1,SString S2);
函数stringconnet.cpp
#include "stringconnet.h"
Status connet(SString &T,SString S1,SString S2)
{ int uncut;
int k=1,j=1;
if(S1[0]+S2[0]<=MAXSTRLEN)
{
while(S1[k]!='#')
{
T[k]=S1[k];
k++;
};
while(S2[j]!='#')
{
T[k+1]=S2[j];
k++;j++;
};
T[0]=S1[0]+S2[0];
uncut=TURE;
}
else if(S1[0]<MAXSTRLEN)
{
while(S1[k]!='#')
{
T[k]=S1[k];
k++;
};
while(j<=MAXSTRLEN-S1[0])
{
T[k]=S2[j];
k++;j++;
};
T[0]=MAXSTRLEN;
uncut=FALSE;
}
else
{
k=1;
while(k<=MAXSTRLEN)
{
T[k]=S1[k];
k++;
};
T[0]=MAXSTRLEN;
uncut=TURE;
}
return uncut;
}
main函数
#include "stringconnet.h"
void main()
{
SString j,k,l;
int i;
cout<<"please enter the string j:";
for(i=0;j[i-1]!='#';i++)
{cin>>j[i];
};
cout<<"please enter the string k:";
for(i=0;k[i-1]!='#';i++)
{cin>>k[i];
};
cout<<"now connet two string:";
connet(l,j,k);
for(i=0;l[i]!='\0';i++)
cout<<l[i];
}
觉得主函数有问题,请求帮助!本人十分感谢!!!!!