• linda (unregistered)

    you people are amazing! i can not stop laughing... i feel that you will destroy my working day today... but anyhow is Saturday, hehe..

    this is the best site i ever read in my life, thus this is only the first thread i read here

    the code in the subject is just such a piece of cake, but the most of the comments WORTH ALL THE MONEY !

    you all have a hug from me!

  • (cs) in reply to anonymous
    anonymous:
    NULL is neither in C nor in C++ standard. It is a pre-processor artifact and usage dates back to beginning of C. Try compiling C/C++ the following program on a Unix system see what happens (clue: it does not compile)

    int main(int c, char **v) { return NULL == 1; }

    Oh really?

    The macro NULL is an implementation-defined C++ null pointer constant in this International Standard (4.10). (ISO 14882:2003, clause 18.1.4.)
    It has a footnote #180 that says "Possible definitions include 0 and 0L, but not (void*)0."

    Just because it's a preprocessor macro doesn't mean that it's not in the standard. Try compiling the following program and see what happens (clue: it does not compile)

    int main() { std::cout << "Hello World\n"; }

    That doesn't mean that cout isn't standardized.

  • (cs) in reply to Dominic

    "Warning 2 warning C4996: 'sprintf' was declared deprecated"

    So what are you supposed to use now? snprintf? what's the new standard?

  • (cs) in reply to GeneWitch
    GeneWitch:
    "Warning 2 warning C4996: 'sprintf' was declared deprecated"

    So what are you supposed to use now? snprintf? what's the new standard?

    Didn't realize that sprintf was deprecated, but probably snprintf since it's not (read: far less) subject to buffer overflows.

  • !Z (unregistered) in reply to DES
    DES:
    Marco Schramp:
    No assigning zero is correct. Actually '\0' == (char) 0 is true.

    It may be on your machine, but the C standard does not guarantee it.

    Yeah it does. \0 is an octal escape. It isn't a special character like \n or \r or \t are. \0 isn't a special 'NUL' escape - it really is just 0.

    e.g. from the gcc manual:

    The octal number escape sequence is the backslash character followed by one, two, or three octal digits (0 to 7). For example, 101 is the octal equivalent of 65, which is the ASCII character 'A'. Thus, the character constant '\101' is the same as the character constant 'A'.

  • Lucifer (unregistered)

    // write the message to a buffer char buffer[N]; sprinf(buffer, "%s: %s\n\r",header,value);

    // remove the carriage return int len = strlen(buffer); buffer[len-2] = 0;

    It is clear why strlen is redundant sprinf(buffer, "%s: %s\n\r",header,value); without \n\r strlen would be not necessary

  • RAB (unregistered) in reply to Felix

    Some DEC systems (RSX? VMS?) used this convention. It was useful because you could end a string with '\n' to push the paper up to display the text without hiding it behind the print head. You'd then start the next line with '\r' to get the print head to the right place before starting to print the next line.

  • xwkqpdne (unregistered) in reply to Dominic

    azptxang http://laktjswm.com adxmmfyo mouvxlqa

  • hrcjnuav (unregistered) in reply to Dominic

    utkwifhs http://xpqyhbcd.com yvvntsxq uwnpakvk

  • TR embedded (unregistered)

    ldx #0 beq testhdr copyhdr: sta buffer,x inx testhdr: lda header,x bne copyhdr lda #":" sta buffer,x inx lda #" " ldy #$ff bne storval nextval: inx iny lda value,y storval: sta buffer,x bne nextval rts buffer: ds N

Leave a comment on “One Step Forward...”

Log In or post as a guest

Replying to comment #:

« Return to Article