Bug in strptime?

rubbah
Posts: 2
Joined: Thu Apr 13, 2023 10:50 am

Bug in strptime?

Postby rubbah » Sun Jan 12, 2025 11:59 pm

Info:
ESP32-C6
ESP-IDF v5.5 (master branch of https://github.com/espressif/esp-idf)


I'm trying to read a string in format "(YYMMDDhhmmssX)"

Code: Select all

#include <time.h>
char* X = NULL;    
struct tm tm;

const char* str_data = "(250111163740W)";
X = strptime(str_data , "(%y%m%d%H%M%S", &tm);
ESP_LOGI(TEST_TAG, "X is: %p\r\n", X);

Code: Select all

TEST: X is: 0x0
X is still NULL (0x0) but it should point to the character W which it doesn't.
Am I miss interpreting how strptime should work?

Tried just compiling a program with gcc.

Code: Select all

#define _GNU_SOURCE
#include <stdio.h>
#include <time.h>

int main()
{
    struct tm tm;
    char *X = NULL;

    const char* str_data = "(250111163740W)";
    X = strptime(str_data, "(%y%m%d%H%M%S", &tm);

    printf("X is: %c, X value: %p\r\n", *X, X);

    return 0;
}

Code: Select all

X is: W, X value: 0x555ddc8d3011

Who is online

Users browsing this forum: Applebot, Baidu [Spider], PerplexityBot and 4 guests