Reputation
7,030
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
15 33
Newest
 Good Answer
Impact
~800k people reached

  • 0 posts edited
  • 0 helpful flags
  • 181 votes cast
2d
comment Different variations of C
Also, I should add that the phrase "close to the machine" simply means that the types and operations defined by the language correspond closely to the types and operations offered by real machines, not that the code is tied to the architecture. Again, if you write strictly conforming code, all you need to do is recompile it for the target platform.
Aug
22
comment Different variations of C
Code that is strictly conforming (uses only the features and libraries defined by the language standard and doesn't make any assumptions about type sizes, representations, or endianness) is highly portable and only needs to be compiled for the target platform. Code that relies on system-specific libraries, data types, etc., will not be as portable, and portions may need to be re-written to run on the new platform.
Aug
11
answered Are data type declarators like “int” and “char” stored in RAM when a C program executes?
Jul
14
awarded  Good Answer
Jun
16
answered What is the difference between function() and function(void)?
May
18
awarded  Good Answer
Apr
24
comment Structuring Procedural vs OO code
@JoeP: The C language itself is simpler than C++, meaning C compilers are easier to implement and verify. There isn't a lot of magic happening under the hood in C code, so it's easier to reason through performance and size issues by simple inspection (i.e., you don't have to worry about potentially expensive constructor/destructor calls, you don't have to worry about expensive copy operations when using the postfix ++ on iterators, stuff like that).
Apr
7
comment Has pre-increment operators become that common?
@iheanyi: the value of y is the value of x prior to the increment; i.e., 1. That's perfectly clear (if you know C). Are you suggesting that the postinc shouldn't be used at all, as in x = 1; y = x; ++x;?
Mar
20
awarded  Pundit
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.