Find first non-repeating character Dry Run in C

Find first non-repeating character 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 first non-repeating character Program Code

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

int main() {
    char str[] = "swiss";
    int freq[256] = {0};
    int len = strlen(str);
    int i;
    printf("String: %s\n", str);
    
    // Count frequency of each character
    for(i = 0; i < len; i++) {
        freq[(int)str[i]]++;
    }
    
    // Find first character with frequency 1
    for(i = 0; i < len; i++) {
        if(freq[(int)str[i]] == 1) {
            printf("First non-repeating character: '%c'\n", str[i]);
            return 0;
        }
    }
    
    printf("No non-repeating character found\n");
    return 0;
}

View the complete String Functions programs page.

Program Console Find first non-repeating character Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.