举样例来说:对于字符串"1234abcdef1234567abcdefghijklmn",这个字串中最长的连续字符串为“abcdefghijklmn”。
int continumax(char *outputstr,char *inputstr) { char maxrecord[100] = {0}; int maxlength = 0; char currentrecord[100] = {0}; int currentlength = 0; char value = 0; char *p = inputstr; while(*p++ != '\0') { if (value + 1 == *p) { value = *p; currentrecord[currentlength] = *p; currentlength++; } else { if (currentlength > maxlength) { maxlength = currentlength; memcpy(maxrecord, currentrecord, currentlength); } currentlength = 0; memset(currentrecord, 0, 100); value = *p; currentrecord[currentlength] = *p; currentlength++; } } if (currentlength > maxlength) { maxlength = currentlength; memcpy(maxrecord, currentrecord, currentlength); } memcpy(outputstr, maxrecord, maxlength); return maxlength; }