Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C string pointers

Name: Anonymous 2010-07-02 9:46

Hi, I've done following ugly thing in C:

void cmd_print_error_start(cmd_err_t error)
{
    char* errstr;
    switch(error)
    {
        case cmd_err_buffer   : { errstr = "BUFFER OVERFLOW"    ; break; }

...

        case cmd_err_rpc_id   : { errstr = "UNKNOWN RPC ID"     ; break; }
    }
    cmd_print("ERROR: %02hX %s", error, errstr);
}


When I compile it with GNU it works, with Keil compiler it spews out random memory until a null byte is reached.
I'm just curious: what does standart say about this? Does anyone know?

Name: Anonymous 2010-07-02 10:03

put a default in your switch.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List