Reputation
4,835
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
2 14 28
Newest
 Good Answer
Impact
~115k people reached

Jun
19
comment FizzBuzz on Large Scale
You want i <= 100, not i < 100. And you need to print the number if and only if you didn't print either fizz or buzz.
Jun
16
comment What is the difference between function() and function(void)?
A C variadic function must be defined with the ... syntax, and it must have at least one named parameter. Defining such a function with () causes undefined behavior -- and there's no way for the body of the function to use the macros defined in <stdarg.h> to read the parameter values. This has been the case since the 1989/1990 standard.
May
20
comment Short circuit evaluation, is it bad practice?
@linac: In C and C++, && is short-circuit and & is not, but they're very different operators. && is a logical "and"; & is a bitwise "and". It's possible for x && y to be true while x & y is false.
Feb
19
awarded  Good Answer
Jan
27
revised Should Perl scripts really have no extension?
added 325 characters in body
Jan
27
answered Should Perl scripts really have no extension?
Jan
27
comment Should Perl scripts really have no extension?
C compilers commonly treat their input files differently depending on the extension. For example, gcc treats . as C source code, .cpp, .cc, .C as C++ source code, .o as an object file to be passed on to the linker, and so on. You can override that with a command-line option, but I've used it so rarely that I don't remember what it is. The .c extension for C source files is important. The .pl extension for executable Perl scripts is not (at least on UNIX-like systems).
Sep
30
awarded  Explainer
Aug
15
comment How does the “Fourth Dimension” work with arrays?
At least in C, a 2-dimensional array is nothing more or less than an array of 1-dimensional arrays. An N-dimensional array is an array of N-1-dimensional arrays. Other languages define these terms differently, but the semantics are similar (though the ordering may vary).
Aug
4
awarded  Yearling
Jul
29
revised printf - source of bugs?
added 196 characters in body
May
6
comment Is converting/casting a boolean to int a good idea?
In C++, the result is well defined. In C, the result is well defined if you're using the built-in bool (_Bool) type, introduced by C99, but older code may define bool in some other way that permits values other than 0 and 1. In Ada, you can't convert a Boolean to type Integer, but the Boolean'Pos attribute yields 0 for False, 1 for True. And so on, with varying answers for all language with a built-in boolean type. I don't believe there's a language-independent answer.
Feb
12
comment What's the difference between syntax and semantics?
To clarify the point, syntax isn't just about the sequence of tokens, it's about how those tokens build up larger constructs. A compiler typically has a lexical analyzer (tokenizer) and a parser as distinct components; both of them deal with syntax.
Feb
12
comment What's the difference between syntax and semantics?
I disagree. The distinction between the two - oeprators is syntactic, not just semantic (though they also have different semantics). Syntax is defined by the language grammar, and the two operators are specified in different sections of the grammar. See the N1570 draft, section 6.5.3 for unary operators and 6.5.6 for additive operators. (BTW, if you're going to use a C example, it should probably be correct; void main() should be int main(void), and you're missing #include <stdio.h> and whatever header declares getch
Feb
8
revised What's the difference between syntax and semantics?
added 21 characters in body
Feb
7
comment Should I change the name of the WTFPL?
@Domenic: My understanding is that "public domain" does have meaning in the US, which is not a commonwealth country.
Feb
6
comment Is there a name for the 'break n' construct?
I find break with a label name (where the label is, ideally, the name of the loop) to be much clearer than break 2. Having the computer require a human to count something is absurd.
Jan
30
comment “Standard” format for using a timestamp as part of a filename
@MikeRosenblum: (Yeah, I'm resonding to a comment from almost 3 years ago.) Spaces in file names can cause problems on some systems.
Jan
30
comment “Standard” format for using a timestamp as part of a filename
I use YYYY-MM-DD-HHMMSS (I might omit the SS in some cases). The date portion is quite readable, and the time portion is readable enough for most purposes.
Jan
28
comment Is there a difference between casting and converting types in imperative programming languages?
@supercat: At least in C, a cast always specifies the same kind of conversion that would be performed implicitly by an assignment to an object of the same type -- if it's one of the conversions (mostly ones between arithmetic types) that can be done implicitly. Other kinds of conversions, e.g., specifying the kind of rounding/truncation for floating-point, can be done via function calls.