c

flush-to-zero behavior in floating-point arithmetic

While, as far as I remember, IEEE 754 says nothing about a flush-to-zero mode to handle denormalized numbers faster, some architectures offer this mode (e.g. http://docs.sun.com/source/806-3568/ncg_lib.html ). In the particular case of this technical documentation, standard handling of denormalized numbers is the default, and flush-to-z...

Storing a 4-bit value in the middle of an 8-bit register

I need to count from 0 to 10 and store those values in binary format in ADCON0(5:2). How do I point at bit 5 of this register? Bit 5 is named ADCON0bits.CHS3. If I store a 4 bit variable to ADCON0bits.CHS3, will bits 1 - 3 be written to bits 4 - 2 of the register? Also, are there any 4 bit data types that I could use? This is all on a ...

How to find all the structs that could be made smaller by changing the order of their members.

Background: The compiler may insert padding into a struct to make it's members align better. This will result in the sizeof the struct being larger than the sum of the sizes of it's members. Reordering the members of the structure so they pack better can remove the need for the compiler to pad in this manner and make the struct smaller s...

Compile string of C code

Really off the wall question here, but is there a way to compile a string of C code in GCC without any medium to hold that string (eg. a source file)? Something along the lines of: $ gcc "#include <stdio.h> int main( void ){ printf('hello world'); return 0;}" -o test Feels really dirty, but it would be really nice if there was some s...

accessing Double pointer

typedef struct _WDF_USB_DEVICE_SELECT_CONFIG_PARAMS { ULONG Size; WdfUsbTargetDeviceSelectConfigType Type; union { struct { PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; PUSB_INTERFACE_DESCRIPTOR* InterfaceDescriptors; ULONG NumInterfaceDescriptors; } Descriptor; struct { PURB Urb; } Urb; struct { UCHAR Numb...

reset a char *array[size] contents

Say I have declared char *array[size] in my program and put some strings in it. If I assign something again to them, they don't replace the previous contents but they keep on appending on the previous contents. How do I correctly clear/reset all of its contents? void function(char* action) { const int myMainArrSize = 3; char *myM...

sendinput to directinput(like games)

I'm trying to simulate keypress to my games that use direct input(I guess). I googled around and I found out the method SendIput(). It work fine if I try to send keypress to notepad.exe but nothing happend when I tried to games. I checked this site http://www.elitepvpers.de/forum/war-hacks-bots-cheats-exploits/170258-simulating-keystrok...

Inserting spaces between digits in C

How would I go about taking a number like 123456 and having it print as 1 2 3 4 5 6? ...

kill thread in pthread

I use pthread_create(&thread1, &attrs, //... , //...); and need if some condition occured need to kill this thread how to kill this ? ...

missing symbols that should be there

I'm stumped. Here is the output of ld. /usr/lib/libvisual-0.6/actor/actor_avs_superscope.so: undefined reference to `visual_mem_free' /usr/lib/libvisual-0.6/actor/actor_avs_superscope.so: undefined reference to `visual_mem_malloc0' Here are the macros: #define visual_mem_new0(struct_type, n_structs) \ ((struct_type *) v...

ALSA: How can I find a device in the device list and still I get "No such file or directory" when opening it?

It seems I don't understand the ALSA architecture, even after reading most of the documentation on offer: I list all the available ALSA devices using snd_device_name_hint() and snd_device_name_get_hint(). This lists, among others "pulse" under hwdep class so it looks like PulseAudio is available in my system. But when I try to open it w...

Arithmetic operations on unsigned and signed integers

See this code snippet int main() { unsigned int a = 1000; int b = -1; if (a>b) printf("A is BIG! %d\n", a-b); else printf("a is SMALL! %d\n", a-b); return 0; } This gives the output: a is SMALL: 1001 I don't understand what's happening here. How does the > operator work here? Why is "a" smaller than "b"? If it is indeed sma...

How to get rid of minus sign from signed zero

I am using asin to calculate the angle. The code is as below : double FindAngle(const double theValue) { return asin(theValue); } FindAngle returns a -0.0 (signed zero), when the argument theValue = -0.0. Now, how do i get rid of the minus sign from the return value. ...

Is there any c/c++ compiler that can warn (or give error) or enum conversion to int?

Cleaning up old c/c++ code that used hardcoded integer literals instead of enums, it is tedious to find places where the function-declaration has been properly refactored but not the body. e.g. enum important { little = 1, abit = 2, much = 3 }; void blah(int e) { // magic stuff here } void boing(int e) { ... } void guck(impor...

How to plot the Histogram of bmp image?

I have got all the pixel values (RGB) of a bmp image. After that, how can i plot the histogram of these values?? I am using C language on my project. Can anyone can help me? Thank you. ...

Printing all environment variables in C / C++

How do I get the list of all environment variables in C and/or C++. I know that getenv can be used to read an environment variable, but how do I list them all? ...

my C program has a char, and I want it to hold more data, what data type do I substitute for it?

I want to modify a program that grabs images from a camera capture board, now its using a char and says its limited to 1000 images, its early/late and I need sleep, so maybe there is a better way to go about this, but I am thinking maybe I could just substitute all the related data variables with higher capacity data types... right now i...

wait and notify in C/C++ shared object

How to wait and notify like in Java In C/C++ for shared memory between two or more thread?I use pthread library. ...

Calling MATLAB from C

I'm writing a Java application that needs to be able to run MATLAB commands. To do so, I'm using a C program that the Java application can call upon to interface with MATLAB. However, even after researching the MATLAB engine, I can't seem to figure out how to compile the C program. This documentation seems to be compiling the C program f...

How one can achieve late binding in C language ?

How one can achieve late binding in C language ? ...