StrCmpZstr

Table of Contents

StrCmpZstr

Description

Compare string with a null-terminated const char* string

Parameters

NameDirectionDescription
strinPointer to Str object to compare with.
zstrinNull-terminated string to compare with.

Usage example (Cross-references)

    WriteFmt("Input: '{}', Output: '{} {}'", in, result1, result2);
    
    bool test2_pass  = (StrCmpZstr(&result1, "HELLO") == 0);
    test2_pass      &= (StrCmpZstr(&result2, "WORLD") == 0);
    WriteFmt("Expected: 'HELLO WORLD', Pass: {}\n\n", test2_pass ? "true" : "false");
    
    bool test2_pass  = (StrCmpZstr(&result1, "HELLO") == 0);
    test2_pass      &= (StrCmpZstr(&result2, "WORLD") == 0);
    WriteFmt("Expected: 'HELLO WORLD', Pass: {}\n\n", test2_pass ? "true" : "false");
    success = success && test2_pass;
    WriteFmt("Input: '{}', Output: '{}{}'", in, result1, result2);
    
    bool test2_pass  = (StrCmpZstr(&result1, "HELLO") == 0);
    test2_pass      &= (StrCmpZstr(&result2, " WORLD MIGHTY MISRA") == 0); // notice the extra space
    WriteFmt("Expected: 'HELLO WORLD MIGHTY MISRA', Pass: {}\n\n", test2_pass ? "true" : "false");
    
    bool test2_pass  = (StrCmpZstr(&result1, "HELLO") == 0);
    test2_pass      &= (StrCmpZstr(&result2, " WORLD MIGHTY MISRA") == 0); // notice the extra space
    WriteFmt("Expected: 'HELLO WORLD MIGHTY MISRA', Pass: {}\n\n", test2_pass ? "true" : "false");
    success = success && test2_pass;
    #define JR_STR_KV(si, k, str)                                                                                          \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    Str my_str = StrInit();                                                                                    \
    si         = JReadString((si), &my_str);                                                                   \
    #define JR_INT_KV(si, k, i)                                                                                            \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    i64 my_int = 0;                                                                                            \
    si         = JReadInteger((si), &my_int);                                                                  \
    #define JR_FLT_KV(si, k, f)                                                                                            \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    f64 my_flt = 0;                                                                                            \
    si         = JReadFloat((si), &my_flt);                                                                    \
    #define JR_BOOL_KV(si, k, b)                                                                                           \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    bool my_b = 0;                                                                                             \
    si        = JReadBool((si), &my_b);                                                                        \
    #define JR_OBJ_KV(si, k, reader)                                                                                       \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    JR_OBJ(si, reader);                                                                                        \
    }                                                                                                              \
    #define JR_ARR_KV(si, k, reader)                                                                                       \
    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    JR_ARR(si, reader);                                                                                        \
    }                                                                                                              \
    char *zstr = generate_cstring(data, offset, size, 20);
    if (zstr) {
    int result = StrCmpZstr(str, zstr);
    (void)result; // Suppress unused variable warning
    free(zstr);

Share :