Tagged Questions
-10
votes
2answers
270 views
Boss is confused by the language - Am I being unreasonable? [closed]
In both C and C++ you can initialize a POD (any struct/union in C) with what C++ calls aggregate initializer lists. Example:
struct abc {
int x;
int y;
char const* ptr;
};
struct abc var = { ...
-1
votes
2answers
121 views
How should I group these variables?
I have a shape that will be defined by:
char s_type;
char color;
double height;
double width;
These variables are scanned in from a request string sent to my server and passed into my printing ...
6
votes
8answers
267 views
What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?
At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of ...
4
votes
3answers
211 views
Do simple accessors and mutators benefit from commented block headers?
Short Question
Is it necessary to add the function header comments for simple accessors and mutators?
Example
u8 OBJ_get_state_x(void) {return obj.state_x;}
void OBJ_set_state_x(u8 x) ...
43
votes
16answers
3k views
Strictness in programming methods among Stack Overflow users [closed]
I've been a member of Stack Overflow for a couple of weeks now and have answered questions and read others answers, mostly in C/C++. True, I have learned about some things. For example, undefined ...
0
votes
2answers
154 views
[C] Address of array elements
What is the most readable way of using address of an array element?
I usually see &array[n] but I personally think array+n looks cleaner and more readable.
What do other C coders prefer?
4
votes
7answers
322 views
Returning from a long function on the first false condition
I have a long(ish) function of the following pattern:
bool func(some_type_t *p1, another_t *p2)
{
bool a = false, b = false, c = false, etc = false;
a = (some_long && expression ...
4
votes
8answers
436 views
Programming style: Reoccuring error checks
Hey, I have a question about programming style, because in my current code I am using a bigger function which calls some smaller functions and all of these need to be error-checked. So something like ...
32
votes
15answers
7k views
If you need more than 3 levels of indentation, you're screwed?
Per the Linux kernel coding style document:
The answer to that is that if you need more than 3 levels of
indentation, you're screwed anyway, and should fix your program.
What can I deduce ...
12
votes
4answers
689 views
If you favor “T *var”, do you ever write “T*”?
Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier (int *i) write code when the identifier is missing?
void ...
13
votes
12answers
1k views
int* i; or int *i; or int * i; [closed]
What is your favorite method to declare a pointer?
int* i;
or
int *i;
or
int * i;
or
int*i;
Please explain why.
see also: http://www2.research.att.com/~bs/bs_faq2.html#whitespace