Strings In Depth10 / 18
Up next

strncmp prefix test

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

int main(void) {
    const char *url = "https://example.com";
    if (strncmp(url, "https", 5) == 0) {
        printf("secure\n");
    }
    return 0;
}
What you're solving

compare only the first n bytes