Case-insensitive comparison (custom logic) Dry Run in C

Case-insensitive comparison (custom logic) 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.

Case-insensitive comparison (custom logic) Program Code

#include <stdio.h>
#include <ctype.h>

int strcmp_ignore_case(const char* str1, const char* str2) {
    while(*str1 && *str2) {
        char c1 = tolower(*str1);
        char c2 = tolower(*str2);
        
        if(c1 != c2) {
            return c1 - c2;
        }
        str1++;
        str2++;
    }
    
    return tolower(*str1) - tolower(*str2);
}

int main() {
    char str1[] = "Hello World";
    char str2[] = "HELLO world";
    char str3[] = "Hello Everyone";
    
    int result = strcmp_ignore_case(str1, str2);
    if(result == 0)
        printf("\"%s\" and \"%s\" are EQUAL (case-insensitive)\n", str1, str2);
    else
        printf("Not equal\n");
    
    result = strcmp_ignore_case(str1, str3);
    if(result == 0)
        printf("Equal\n");
    else
        printf("\"%s\" and \"%s\" are NOT equal\n", str1, str3);
    
    return 0;
}

View the complete String Functions programs page.

Program Console Case-insensitive comparison (custom logic) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.