6,750 reputation
1233
bio website
location Manor, TX
age 49
visits member for 4 years, 1 month
seen 3 hours ago

Professional software developer since 1990. Primary development experience is high-level application logic using C and C++ on a variety of platforms, mostly Unix or linux. Some professional experience with Java and various flavors of SQL and RDBM systems.


Jan
12
comment int * vs int [N] vs int (*)[N] in functions parameters. Which one do you think is better?
@elias: int (*a)[] is an incomplete type; it's legal as long as you don't try to do anything that requires the size of the type to be known. For example, you couldn't use sizeof *a to get the size of the array in that case. Also, remember that a pointer to an N-element array is a different type from a pointer to an M-element array; they won't be interchangeable. As a matter of safety, you always want to specify the size of the array parameter.
Jan
11
answered int * vs int [N] vs int (*)[N] in functions parameters. Which one do you think is better?
Dec
22
answered Disadvantages of Pointers
Dec
21
awarded  Yearling
Dec
19
answered How can this allocation of bi-dimensional arrays work?
Dec
16
answered Use of for loop conditional statement unrelated to iterating variable
Dec
10
comment Why do we have to tell printf() the type of data in C?
@user31782: Not without a change to the language definition. Sure, it's possible (C++ is also statically typed, but is able to infer types for the << and >> I/O operators), but it would add some complexity to the language. Inertia is hard to overcome sometimes.
Dec
5
comment Why do we have to tell printf() the type of data in C?
@user31782: What if you want to display the value as hex? Octal? What if you want the field width to be 10 characters wide with leading 0s? What if you only want to display 2 decimal places for floats? What if you want to display 21 decimal places? What if you want strings to be no wider than 20 characters? This is why the compiler doesn't fill in the format string for you, because you're the one who knows how you want your output formatted. It would be nice to just have a generic placeholder that didn't care about type, but C just doesn't work that way.
Dec
5
comment Why do we have to tell printf() the type of data in C?
@user31782: see my edit.
Dec
5
revised Why do we have to tell printf() the type of data in C?
added 11917 characters in body
Dec
4
comment Why do we have to tell printf() the type of data in C?
@user31782: printf formats all its output as text (ASCII or otherwise); the conversion specifier tells it how to format the output. printf( "%d\n", 65 ); will write the sequence of characters '6' and '5' to standard output, because the %d conversion specifier tells it to format the corresponding argument as a decimal integer. printf( "%c\n", 65 ); will write the character 'A' to standard output, because %c tells printf to format the argument as a character from the execution character set.
Dec
4
comment Why do we have to tell printf() the type of data in C?
@user31782: Yes, because that's what putchar does - it prints characters from the execution character set to standard output based on the value passed to it. For example, if the execution character set is ASCII and you pass an integer value of 65, putchar will write the character 'A' to standard output, since 65 is the ASCII code for 'A'. putchar(65); and putchar('A'); yield the same output, because the value of the character constant 'A' is 65 (assuming ASCII).
Dec
4
comment Why do we have to tell printf() the type of data in C?
@user31782: The definition of the putchar function says that it expects 1 argument of type int; when the compiler generates the machine code, that machine code will assume that it always receives that single integer argument. There's no need to specify the type at runtime.
Dec
3
answered Why do we have to tell printf() the type of data in C?
Dec
1
awarded  Nice Answer
Dec
1
comment Advantages of unmanaged code
@Deduplicator: That too. And native code can interoperate with other native code pretty easily, as long as everyone's using the same calling conventions.
Dec
1
revised Advantages of unmanaged code
added 205 characters in body
Dec
1
revised Advantages of unmanaged code
added 332 characters in body
Dec
1
answered Advantages of unmanaged code
Oct
23
comment Explicitly define enum values, even if the default value is the same?
If there's a requirement that specific enumeration identifiers map to specific values, then those values should be explicitly specified whether they coincide with the defaults or not. Along with a comment that explains why those values must be specified.