je-so
Re:Personal Space Is a Fear Response
on Monday January 25, 2016 @08:25AM (#10967012)
Personal space is a natural right!
Even animals has this right except farm animals.
If you know that sizeof(float) >= sizeof(int) the memory alignment should be fine. Also in this case * (int* )&a does not access any bytes outside of an defined data object.
To predict the outcome one have to know the representation of float (IEEE 754) and the big/little endian issues which could be different between floats and ints.
printf("%d\n", a) does promote the value a to a double first (promotion rules) and then either the first or last part i(assuming sizeof(double) == 2*sizeof(int)) is shown depending on little or big endian architecture.
Re:Are pointers and arrays equivalent in C? (2009)
on Saturday March 21, 2015 @01:10PM (#9243363)
Another interesting thing to know about pointer and arrays is:
#include <stdio.h>
typedef int a_t[100];
int main(void)
{
int a[100];
a_t* p = &a;
// all printed pointer values are equal
printf("%p %p %p %p\n", (void*)a, (void*)&a, (void*)p, (void*)*p);
return 0;
}
Re:15-line hash table in C
on Friday December 12, 2014 @01:34AM (#8738836)
(See http://pastebin.com/KypbginU)
// corrected overflow hget
for (int k2=k,o=0; t[k&(SIZE-1)] && **t[k&(SIZE-1)] != k2 && o<SIZE; ++k,++o);
return t+(k&(SIZE-1));
// hset now allows overwrite for (int (**a)[2] = hget(t, k); a && (*a || (*a=malloc(sizeof(**t)))); (**a)[0]=k,(**a)[1]=v,a=0);