STRCHAR()

this function filters a specific character within a larger string. input validation is a common use-case such as when identifying whether a given user input contains forbidden characters that may break a backend database.

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

int main() {
    // Declare and initialize a sample email address
    char email[] = "[email protected]";

    // Use strchr to find the '@' character
    char *result = strchr(email, '@');

    // Check if the character was found
    if (result != NULL) {
        printf("Character found!\n");
    } else {
        printf("Character not found!\n");
    }

    return 0;
}

Last updated