lundi 15 mars 2021

C - checking if strings contain any non-null characters

I have a function with two strings parameters. I have to check if both strings contains any non-null characters. Here is an example code:

void fun(const char* str1, const char* str2)
{
    if (!str1 || !str1[0] || !str2 || !str2[0])
    {
        return;
    }

    // process
}

Is that a standard approach in C or you recommend other solution ?

Aucun commentaire:

Enregistrer un commentaire