Print all substrings of a string Dry Run in C

Print all substrings of 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.

Print all substrings of a string Program Code

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

int main() {
    char str[] = "abc";
    int len = strlen(str);
    int total = 0;
    
    printf("String: %s\n", str);
    printf("All substrings:\n");
    
    // Generate all substrings
    for(int i = 0; i < len; i++) {
        for(int j = i; j < len; j++) {
            // Print substring from i to j
            for(int k = i; k <= j; k++) {
                printf("%c", str[k]);
            }
            printf("\n");
            total++;
        }
    }
    
    printf("Total substrings: %d\n", total);
    return 0;
}

View the complete String Functions programs page.

Program Console Print all substrings of a string Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.