Category "c"

bitwise operators with an if

I am reading K&R book for c language and in section 2.10 they give the following example: /*bitcount: count 1 bits in x*/ int bitcount(unsigned x) { in

How to check that SDP service record was registered correctly in C++/Linux

I am trying to register my bluetooth SDP service in C++ linux as shown here: Example 4-9. Describing a service Where or how can I check exactly that the servic

GCD function for C

Q 1. Problem 5 (evenly divisible) I tried the brute force method but it took time, so I referred few sites and found this code: #include<stdio.h> int gcd

Java equivalent of #ifdef that allows non-compilable code

Is it possible in Java to do a sort of #ifdef thing, like in C/C++? Example: class Test { public static final boolean ANDROID = false; public Test()

Is there an equivalent C# syntax for C's inline anonymous struct definition?

Greetings Overflowers, I know in C we can define a struct inline with the variable declaration so that the struct type is specific to this variable. This is in

Count the number of occurrences of each letter in a string

This is my logic. I wrote function for counting the no. of occurrences of each letter in a string. But this doesn't work correctly. Correct me. void countChar(c

Count the number of occurrences of each letter in a string

This is my logic. I wrote function for counting the no. of occurrences of each letter in a string. But this doesn't work correctly. Correct me. void countChar(c

Sum of two chars in C/C++

In C/C++ when I want to find sum of two chars - I get result in int. For example: #include <stdio.h> int main(){ char a = 'a', b = 'b'; printf("%d

Would float point format be affected by big-endian and little endian?

I know the integer format would be different between big-endian machine and little-endian machine, is it the same for float point format (IEEE 754)?

Is C open source?

Does C (or any other low-level language, for that matter) even have source, or is the compiler the part that "does all the work", including parsing? If so, coul

Why should I always enable compiler warnings?

I often hear that when compiling C and C++ programs I should "always enable compiler warnings". Why is this necessary? How do I do that? Sometimes I also hear

Performance of built-in types : char vs short vs int vs. float vs. double

Seeing Alexandre C's reply in the other topic, I'm curious to know that if there is any performance difference with the built-in types: char vs short vs int vs

How to scp from a C program?

The following C program compiles and spits out a a directory listing of "/Users/home/tempdir" directory. #include <stdio.h> #include <unistd.h> i

AVR ATMEGA328 is Resetting when (TIMER1_CAP_VECT)Interrupt Occurs and sometime with the UART interrupt

I configure the ICP1 to get the pulses but when it happens, the avr is resetting, sometimes when the uart iterrput occurs it also reset. I don't know where I'm

while ((c = getchar()) != EOF) Not terminating

I've been reading "The C Programming Language" and I got to this part of inputs and outputs. I've read other threads saying that the console doesn't recognize e

X11: Detect general Mouse and Keyboard events

Is there a way to detect if the mouse has been moved ANYWHERE on the X Server or a keyboard event occured? I need to react on the user doing anything with the X

Embedding resources in executable using GCC

I'm looking for a way to easily embed any external binary data in a C/C++ application compiled by GCC. A good example of what I'd like to do is handling shader

How to find the socket connection state in C?

I have a TCP connection. Server just reads data from the client. Now, if the connection is lost, the client will get an error while writing the data to the pipe

Decrementing and incrementing a variable with an if condition produces unexpected result in C language

I'm running this code from the command prompt. The output of this code is 0 but I was expecting it to output 1. Can you explain how this code is actually compi

How can I know the version of c?

The "\b" didn't work on my Mac. So I tried to find the reason. I think that cause of this problem may be the version of C. Or device could be. If you know it, c