- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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!
Admin
Oh really?
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.
Admin
"Warning 2 warning C4996: 'sprintf' was declared deprecated"
So what are you supposed to use now? snprintf? what's the new standard?
Admin
Didn't realize that sprintf was deprecated, but probably snprintf since it's not (read: far less) subject to buffer overflows.
Admin
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'.
Admin
// 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
Admin
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.
Admin
azptxang http://laktjswm.com adxmmfyo mouvxlqa
Admin
utkwifhs http://xpqyhbcd.com yvvntsxq uwnpakvk
Admin
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