Frequency function in C

I wrote a program that should take a string and a letter, then call a function which have two parameters (the string, the letter) and then count frequency of letter in the string. The problem with my code is that it always returns num with value zer...
more »

2017-05-14 20:05 (4) Answers

Difference between cpp and gcc -E

I thought that both cpp foo.c and gcc -E foo.c do preprocess the source file the same way, but I got their output to differ for the same file. $ cat foo.c #define VARIABLE 3 #define PASTER(x,y) x ## _ ## y #define EVALUATOR(x,y) PASTER(x,y) #define...
more »

2017-05-14 20:05 (1) Answers

About binary search in helpers.c

Why is my function returning false? I have tried to debug it and it should return true but does not. And if I remove return 1 from the very end of bool search function it gives error: control may reach end of non-void function I know it may l...
more »

2017-05-14 16:05 (2) Answers

Why doesn't GCC throw a warning in this example

With -Wsequence-point enabled, GCC should warn user when unexpected behaviour code is spotted. For example b = a + ++a; should be noticed by GCC and should be reported as "unexpected behaviour" code (because ISO C doesn't specify the order of eval...
more »

2017-05-14 13:05 (1) Answers

Difference between variables' addresses

Why do variable addresses differ by a specific amount each time I run a program (as in "printf("%d %d\n", &a, &b);". It will print "1000 988" in one run, "924 912" in another, "1288 1276", and so on and so forth)? Does the compiler occupy a s...
more »

2017-05-14 11:05 (3) Answers

Does Mac OS X have the /dev/ptmx file?

I want to port my Linux application that uses pseudo-terminals to OS X, but I can't seem to find the /dev/ptmx file on my OS X Tiger. Is it because OS X Tiger is so old, and newer versions have this file? ...
more »

2017-05-13 19:05 (1) Answers

Checking abc alphabet on C language

I just started to learn loops on C language. Write a program that checks if the input of abc alphabet is correct, the input is small letters form abc alphabet, asume that the input is orderd, if misissing some latters you should add the missing l...
more »

2017-05-13 16:05 (2) Answers

cross-platform keyboard handling

How can we rewrite the following function/mechanism to work in cross-platform environments? BOOL WasKeyDown(KEY_CODE key) { if (0x00000001 & GetAsyncKeyState(key))//least significant bit is high return TRUE; ...
more »

2017-05-13 12:05 (0) Answers

macOS documentation for structs in Security.h

I'm trying to use the Security.h macOS framework via Java and JNA. That means I need to reconstruct certain structs as Java classes. The problem is, when I look at the docs for a struct (this one, for example), all I see is a brief description of th...
more »

2017-05-13 08:05 (1) Answers

Single PAM conversation with multiple messages

I'm helping build a pluggable access module. Our module initially implemented a PAM conversation with only one message, and it worked fine. We then had a need to add a second message to the conversation, and thought it would be simple enough to incre...
more »

2017-05-12 10:05 (0) Answers

Setting up signal masks in a Linux C daemon

I have written a simple daemon in C, running on Linux. I'm trying to understand how to correctly setup signal masks. I have the following code in my daemon: struct sigaction new_sig_action; sigset_t new_sig_set; /* Set signal mask - signals we want...
more »

2017-05-12 08:05 (1) Answers

Force UTF-8 encoding in glib's "g_print()"

Short question: Is there a way to force glib's g_print() to use UTF-8 encoding? The problem I hit is that g_print() seems to do character set conversion based on the return value of g_get_charset(). Now the documentation unfortunately mentions ...
more »

2017-05-12 01:05 (1) Answers

Magnetometer data on MPU-9250 (uClinux)

I've found a few other people ask about this, but all of them are coding in Arduino, and I'm struggling to translate it into my project. I'm on a research team developing a Cube Satellite for launch, and my role is to communicate with the periphera...
more »

2017-05-11 17:05 (1) Answers

the size of dynamically allocated array in C

I know that this question has been asked before, but my question is more specific, here is the code: #include <stdio.h> #include <time.h> /* must be included for the time function */ main() { time_t t = time(NULL); srand((uns...
more »

2017-05-11 14:05 (4) Answers

Getting error while building in Jenkins

I'm new to Jenkins and I'm trying to build, and i'm geting the following error in console. Please Help! I've resolved most of the problems that i could. I'm followin tutorial: "http://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html...
more »

2017-05-10 22:05 (0) Answers

Boxing/Unboxing complex types in Julia

I have basically digged through all Julia documentation, but I cannot find any answers on this. My question can be split into two parts. Code snippets ignore stuff like basic s initialization. Part 1: How to pass basic complex types without jl_eval_...
more »

2017-05-10 21:05 (1) Answers