Category "c"

How to run a c program in ubuntu 12.04

Hello i am new to ubuntu. I want to run a c program in ubuntu.On the terminal i typed "make ex1.c" (my file name is ex1) and the after pressing enter button , t

What does reaping children imply?

I have just had a lecture that sums reaping as: Reaping Performed by parent on terminated child (using wait or waitpid) Parent is given exit status informato

kernel make error "arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to"

This error stops my kernel make process ld: arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to `__x64_sys_fd' BTF .btf.vmlinux.bin.o pahol

How to implement google mock to mock the C fopen function

I am writing a unit test for embedded C codes using google test/mock. The C function code looks like this. int readGPIOSysfs(int ioport){ ... FILE *f = fop

Sleeping barber using semaphore

I am having a problem in the synchronisation of threads. I m trying to implement sleeping barber problem in a different approach. When i run the code the thread

two pass assembler fix

I'm working on a 2 pass assembler and have been looking at sample codes online to familiarise myself. I found the following code but there appears to be a probl

two pass assembler fix

I'm working on a 2 pass assembler and have been looking at sample codes online to familiarise myself. I found the following code but there appears to be a probl

C: Custom strlen() library function

I created my version of strlen() function. unsigned int my_strlen(char *p) { unsigned int i = 0; while(*p!='\0') { i++; p++; }

Cmocka: checking a structure passed as a parameter

Let's say that I declare a C struct called foo, which has an int field called bar and a char * called baz. How do I use the Cmocka expect_ and check_expected m

Problem with EOF when determining stream end

When I try to determine end of file with function feof(FILE *), I find it does not work as I expected: an extra read is required even if the stream does end. E.

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