c Questions

Dinah   2018-07-04 04:41

With arrays, why is it the case that a[5] == 5[a]?

As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] == 5[a] Joel says that it's because of pointer ...
Matt   2018-07-05 07:22

How to initialize all members of an array to the same value?

I have a large array in C (not C++ if that makes a difference). I want to initialize all members to the same value. I could swear I once knew a simple way to do this. I could use memset() in my case, ...
Mark Harrison   2018-07-05 14:15

How do I determine the size of my array in C?

How do I determine the size of my array in C? That is, the number of elements the array can hold?
George   2018-07-07 06:16

C pointer to array/array of pointers disambiguation

What is the difference between the following declarations: int* arr1[8]; int (*arr2)[8]; int *(arr3[8]); What is the general rule for understanding more complex declarations?
Mike Willekes   2018-07-18 07:21

Improve INSERT-per-second performance of SQLite?

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...
Patrick McDonald   2018-07-18 08:15

Do I cast the result of malloc?

In this question, someone suggested in a comment that I should not cast the result of malloc, i.e. int *sieve = malloc(sizeof(int) * length); rather than: int *sieve = (int *) malloc(sizeof(int) * ...
JeffV   2018-07-18 10:23

How do you set, clear, and toggle a single bit?

How do you set, clear, and toggle a bit in C/C++?
Johannes Gerer   2018-07-18 12:14

Why are elementwise additions much faster in separate loops than in a combined loop?

Suppose a1, b1, c1, and d1 point to heap memory and my numerical code has the following core loop. const int n = 100000; for (int j = 0; j < n; j++) { a1[j] += b1[j]; c1[j] += d1[j]; } ...
quest49   2018-07-18 13:05

What is the difference between #include <filename> and #include “filename”?

In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement, as follows? #include <filename> #include "filename"
Peter Olson   2018-07-18 14:50

What does the C ??!??! operator do?

I saw a line of C that looked like this: !ErrorHasOccured() ??!??! HandleError(); It compiled correctly and seems to run ok. It seems like it's checking if an error has occurred, and if it has, it ...