Q:

Calculating characters apperances in a row

Program i've wrote is calculating how many times each letter appears in a string. I want to change it that it will find the character that appears the great amount of times in a row i.e. for the string "aabbbcccca" i want to printf "c" (as there are four c in a row and only two a and three b).
How to change my program that it will do the things i want? I am looking for the solution that will be as simple as possible and I want to use the existing code as much as possible.
#include "stdafx.h"
#include "string.h"
#include "ctype.h"

int count_nonspace(const char* str)
{
    int count = 0;
    while (*str)
    {
        if (!isspace(*str++))
            count++;
    }
    return count;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int a[127];
    int i = 0, j = 0, count[127] = { 0 };

    char string[100] = "Hello world";
    for (i = 0; i < strlen(string); i++)
    {
        for (j = 33; j<127; j++)
        {
            if (string[i] == (j))
            {
                count[j]++;
            }
        }
    }
    for (j = 0; j< 127; j++)
    {
        if (count[j] > 0)
        if (j < ' ' + 1) 
            printf("\n%d -> %d", count[j], j);
        else
            printf("\n%d -> %c", count[j], char(j)); 
    }

}

My idea for changing the code is the following (posted only the changed part):
but still results are not as anticipated, why is that?
for (i = 0; i < strlen(string); i++)
{
    for (j = 33; j<127; j++)
    {

        if (string[i] == (j))
        {

            count[j]++;
            if (string[i] == string[i + 1])
                count[j]++;
            else
                best[j] = count[j];
        }
    }
}

A:

#include "stdafx.h"
#include "string.h"
#include "ctype.h"

int count_nonspace(const char* str)
{
    int count = 0;
    while (*str)
    {
        if (!isspace(*str++))
            count++;
    }
    return count;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int a[127];
    int i = 0, j = 0, count[127] = { 0 };

    int cur_count = 1; /* Gets compared with value in count[] */
    char cur_char = '\0';
    char string[100] = "Hello world";
    for (i = 0; i < strlen(string); i++)
    {
        if(cur_char == string[i])
        {
            cur_count++;
        }
        else
        {
            if(32 < cur_char && cur_char < 127)
            {
                if(cur_count > count[cur_char])
                {
                    count[cur_char] = cur_count;
                }
            }
            cur_char = string[i];
            cur_count = 1;
            if(32 < cur_char && cur_char < 127)
            {
                if(!(count[cur_char]))
                {
                    count[cur_char] = cur_count;
                }
            }
        }
    }

    /* Find the most consecutive char and print it. */
    char max_char = '\0';
    int max_count = 0;
    for(j = 0; j < 127; j++)
    {
        if(max_count < count[j])
        {
            max_count = count[j];
            max_char = j;
        }
    }
    printf("%c\n", max_char);
}

