Category "c"

Can sizeof(size_t) be less than sizeof(int)?

Can sizeof(size_t) be less than sizeof(int)? Do the C and/or C++ standards guarantee that using unsigned int for array indexing is always safe?

Why is printf round floating point numbers up?

I am trying to print some floating point numbers using printf. For example: int main() { printf("%.1f",76.75); return 0; } Output: 76.8 And I have som

How to create UDP socket connection to receive data from gstreamer udpsink?

I want to create a UDP socket connection to receive data from GStreamer udpsink. When I create a Gstreamer pipeline using udpsink, VLC can play the stream. I wa

GtkStatusIcon label in Gnome3

How can affect on my app's status icon label in Gnome3? When i moving cursor on it shows me my app's executable name. How can I change it?

Idiomatic way to check for non-zero

When I wish to check if a value is 0 in C, how is it idiomatically done? if (!num) if (num == 0)

Define data type of enum in C for memory

I could not find a direct answer to this but is it possible to force a certain kind of data type for an enum in C ? e.g I have an enum for a state machine that

building kernel module and resolve missing symbol definitions

If I build a module which depends on other modules, and i get this warning: 'function or symbol ?' [source dir/my_module.ko] undefined! What does the warn

Check whether a path is absolute or relative

How do you check whether a path is absolute or relative, using C on Linux?

C - forward declaration of enums?

Forward declaration of enums in C does not work for me. I searched the internet and Stack Overflow but all of the questions regarding forward declarations of en

Why does the indexing start with zero in 'C'?

Why does the indexing in an array start with zero in C and not with 1?

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.