Find repeated characters in a string Dry Run in C

Find repeated characters in a string is an interactive C dry run visualizer from the String Functions programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Find repeated characters in a string Program Code

#include <stdio.h>
#include <string.h>

int main() {
    char str[] = "programming";
    int freq[256] = {0};
    int len = strlen(str);
    int printed[256] = {0};
    int i;
    printf("String: %s\n", str);
    printf("Repeated characters: ");
    
    // Count frequencies
    for(i = 0; i < len; i++) {
        freq[(int)str[i]]++;
    }
    
    // Print characters with frequency > 1
    for(i = 0; i < len; i++) {
        if(freq[(int)str[i]] > 1 && printed[(int)str[i]] == 0) {
            printf("%c ", str[i]);
            printed[(int)str[i]] = 1;
        }
    }
    printf("\n");
    
    return 0;
}

View the complete String Functions programs page.

Program Console Find repeated characters in a string Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.