Sometimes edit, sometimes reply.
Code:
#include<stdio.h>
void foo(const char *concat)
{
#if 0 /* dangling code presumed to be part of 'foo' */
// what is concat, really?
// what is count?
// what is count2?
// what is a?
// what is b?
// do you realize that a+1 might be outside of concat[]?
// do you realize that b+2 might be outside of concat[]?
// do you realize that b+3 might be outside of concat[]?
for ( ;concat[a] != '\0';a++ )
{
for ( ;concat[b] != '\0';b++ )
{
if ( concat[a]==concat[b+2] && concat[a+1]==concat[b+3] )
{
count++;
if ( count>count2 )
{
count2=count;
count=1;
printf(" %c%c", concat[b+2], concat[b+3]);
printf(" %d",count2);
}
else if ( count==count2 )
{
count=1;
printf(" %c%c", concat[b+2], concat[b+3]);
printf(" %d",count2);
}
}
}
}
#endif
}
int main(void)
{
foo("th");
return 0;
}
[edit]
Code:
#include <stdio.h>
void foo(const char *text)
{
int i, j, consecutive;
for ( i = 0; text[i] != '\0'; i += j )
{
consecutive = 1;
for ( j = 1; text[j + i] == text[i]; ++j )
{
++consecutive;
}
printf("so far, '%c' has %d consecutive\n", text[i], consecutive);
}
}
int main(void)
{
foo("iii aaammm cccooonnnffffffuuuuuuuuussssssssssseeeeeeeeedddd");
return 0;
}
/* my output
so far, 'i' has 3
so far, ' ' has 2
so far, 'a' has 3
so far, 'm' has 3
so far, ' ' has 3
so far, 'c' has 3
so far, 'o' has 3
so far, 'n' has 3
so far, 'f' has 6
so far, 'u' has 9
so far, 's' has 11
so far, 'e' has 9
so far, 'd' has 4
*/