check if string starts with c

Checking if a String Starts with "c" in C Language

To check if a string starts with "c" in the C language, you can use the strncmp function to compare the first character of the string with "c". Here's an example of how you can do this:

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

int main() {
    char str[] = "example";

    if (strncmp(str, "c", 1) == 0) {
        printf("The string starts with 'c'\n");
    } else {
        printf("The string does not start with 'c'\n");
    }

    return 0;
}

In this example, the strncmp function is used to compare the first character of the string str with "c". If the first character is "c", it will print "The string starts with 'c'", otherwise it will print "The string does not start with 'c".

[[SOURCE 1]]