关于连续最长的字符串有关问题,自己摆弄了一天,没弄明白。求教

关于连续最长的字符串问题,自己摆弄了一天,没弄明白。求教。
/*
在一个字符串中找出连续最长的字符串,并把这个最长的字符串返回。如果存在长度相同的连续字符串,返回最后一个字符串
注意,数字不光要连着,还需要是连续的,比如1234,而不是1245,如果没有数字,则返回空字符串“” 而不是NULL!
样例输入
abcd12345ed1255ss123456789 
abcd12345ss54321
样例输出
123456789,函数返回值9
54321,函数返回值5
接口说明
函数原型:
unsigned int Continumax(char ** pOutputstr,char * intputstr)
输入参数:
char * intputstr 输入字符串
输出参数:
char ** pOutputstr 连续最长的数字串,如果连续最长数字串长度为0,应该返回空字符串,如果输入空字符串也应该返回空字符串
返回值:连续最长的数字串的长度
*/
#include <iostream>
#include <Cstring>
using namespace std;
bool shengjiang(char * intputstr,int i,int nLen)
{
int nNum = nLen;
int nI = i;
if (intputstr[i]>intputstr[i-1])
{
if (intputstr[i]!=intputstr[i-2]+2)
{
return false;
}
}else
{
if (intputstr[i]!=intputstr[i-2]-2)
{
return false;
}
}
return true;
}
unsigned int _Continumax(char ** pOutputstr,char * intputstr)
{
int nLen = 0;
int pos = -1;
int MaxLen = 0;
char *szCru = new char[strlen(intputstr)];
szCru ="";
char *szMax = new char[strlen(intputstr)];
szMax = "";
for (int i=0;i<strlen(intputstr);i++)
{
if (intputstr[i]>='0'&&intputstr[i]<='9')//判断是否为数字
{
nLen++;
//判断大小的连续性
if (nLen>=2)
{
if ((intputstr[i] != intputstr[i-1]+1)&&(intputstr[i] != intputstr[i-1]-1))//相邻的两个数不是连续的
{
nLen =0;
/*pos = i+1;*/
break;
}
}
//考虑递增递减关系
if (nLen>=3)
{
if (!shengjiang(intputstr,i,nLen))//不是升序也不是降序
{
nLen = 0;;
break;
}
}
if (nLen==1)
{
strcpy(szCru,&intputstr[i]); //这个位置会报中断,要怎么改才好?
}else
{
strcat(szCru,&intputstr[i]);//这里应该也是有问题的。
}
if (nLen>MaxLen)
{
MaxLen = nLen;
strcpy(szMax,szCru);
/*pos = i+1;*/
}

}else
{
nLen =0;
//把当前buff清空
szCru = "";
/*pos = i+1;*/
}
}
pOutputstr = &szMax;

if (szCru)
{
delete [] szCru;
}
if (szMax)
{
delete [] szMax;
}
return MaxLen;
}
int main()
{
char intputstr[256];
char pOutputstr[256]="";
char *q = pOutputstr;
char **p = &q;
//输入字符串
cin.get(intputstr,256);
int MaxNum = _Continumax(p,intputstr);
cout<<*pOutputstr<<","<<MaxNum<<endl;
return 0;

------解决思路----------------------
你的程序有明显的问题:
               line 47和line 49:    你新new出来两段内存,然后却将szCru和szMax指向了空字符串。注意你这里不是赋值,是改变指针指向!!此后的一切操作都肯定非法。
               line 24 和 25, nI和nNum定义后根本没有使用过;
               你的程序的算法我稍微研究了下,没看下去。你应该再多写一些注释,把思路写上去,这样更明晰

给你我的答案:
  1  /*step 1) 找到下一个数字序列的起始位置
  2  *         2) 根据升或者降一直找到这个序列的符合要求的最后一个数字,然后获得这个序列的长度
  3  *         3) 如果这个序列比之前得到的最长序列还要长,把这个序列的起始位置和长度记录下来,顶替上一个最长序列
  4  */
  5 
  6 #include <ctype.h>
  7 #include <string.h>
  8 #include <stdio.h>
  9 const int EndReached = 0;
 10 const int MAXLENGTH = 128;
 11 int getNextNumberSequence(const char*, unsigned int*);
 12 
 13 int main()
 14 {
 15         char input_str[MAXLENGTH];
 16         printf("please input the string\n");
 17         scanf("%s",input_str);
 18         unsigned int cur_pos = 0, end_pos;
 19         /*cur_pos is the current positon in the input string, end_pos is the end position of the next number sequence\
 20          * in the input string*/
 21         unsigned int maxseq_len = 0, maxseq_beg, maxseq_end;
 22         /*seq_len is the length of the longest number sequence, maxseq_beg and maxseq_end are its positions\