Abort trap: 6 error when working with array in C

I am a beginner to C and am trying to get more familiar with arrays and the concept of manual memory allocation by doing simple exercises. I have been reading all the (many) questions on SO regarding the "Abort trap: 6" error, and though I've learned...
more »

2017-08-17 05:08 (2) Answers

sscanf usage in very specific format

I'm trying to use sscanf with a string that is exactly in the following format: integer1 integer2 so that i can store int1 and int2 into an array I want sscanf to check if only two numbers are entered separated by only ONE space, with no leadi...
more »

2017-08-16 18:08 (2) Answers

Concatenate arguments using strcpy

I want to concatenate all my arguments into a char pointer using strcpy. I'm doing this but my output is only a space. I'm using 3 variables: 'concat' ( which should be my output ) , 'size' to get the length of all the arguments and 'kar' which is m...
more »

2017-08-16 16:08 (4) Answers

Is this Bubble sort or insertion sort in C?

I have written this code by understanding the insertion sort algo. My teacher says its bubble sort but my friends are saying it is insertion. Could someone please check and brief me on this. #include <stdio.h> void sort(int n) { int i, j; ...
more »

2017-08-16 12:08 (3) Answers

Print braille characters in ncurses

I attempted to print braille characters in ncurses. This is my code: #include <ncurses.h> char *str = " ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏\n" "⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟\n" "⠠⠡⠢⠣⠤⠥⠦...
more »

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

Free TLS pointers for every thread

Reading the following page in MSDN: Using Thread Local Storage in a Dynamic-Link Library I can't understand who is responsible for freeing the memory pointed by the TLS slot of each thread in the case of a FreeLibrary() call. From what I understan...
more »

2017-08-16 10:08 (1) Answers

Loop exit condition on fgets doesn't work

I have a text file like this "input" height : 227 width : 227 depth : 3 "conv" num_output : 96 pad : 0 kernel_size : 11 stride : 4 group : 1 "relu" "pool" kernel_size : 3 stride : 2 I'm reading it in a loop (this is partial code) char line[100...
more »

2017-08-15 21:08 (4) Answers

How I can remove all odds bits in C?

I have int 136970250 (1000 0010 1010 0000 0000 0000 1010) -> I need to remove all odd bits(1, 3, 5, 7...) 1000 0010 1010 0000 0000 0000 1010 -> 10 0111 0000 0011 (9987) - because this bits do not have information. How to do it? ...
more »

2017-08-15 16:08 (3) Answers

How to calculate CRC using this code?

I'm trying to get going radio communication between a device and my server. Data from the device looks like this: fa-00-01-09-16-aa-00-14-10-01-01-00-01-16-ff-ff-ff-ff-ff-ff-cb-14 where last two bytes are CRC. Now I need to send reply to my device...
more »

2017-08-15 12:08 (2) Answers

/* ARGSUSED */ and other special comments

I've searched on SO and googled but I don't get meanings of them. What are they and their purposes? When are they used? I think that maybe I'm too late to see them in modern-day programming and in my generation. Some of them AFAIS, /* ARGSUSED */ ...
more »

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

socket programming , bind() error

My code which I have written for server implementation is not working. program cant bind() socket address properly and generate error. Code #include<stdio.h> #include<unistd.h> #include<sys/types.h> #include<sys/socket.h> #i...
more »

2017-08-15 04:08 (1) Answers

is a compound literal not a literal?

From C in a Nutshell: Chapter 3 Literals In C source code, a literal is a token that denotes a fixed value, which may be an integer, a floating-point number, a character, or a string. A literal’s type is determined by its valu...
more »

2017-08-15 01:08 (1) Answers

Different conventions for main() in C

My only exposure to programming has been Java,where I have not encountered (up to now) different conventions for writing the main method.I have been following to sources for learning c (K&R AND C Programming A Modern Approach) where they use very...
more »

2017-08-14 19:08 (4) Answers

Multiple errors from C assert macro

I have a assert macro that's defined as: #define likely(cond) (__builtin_expect((cond), 1)) #define unlikely(cond) (__builtin_expect(!!(cond), 0)) static void assert_fail(const char *__assertion, const char *__file, unsig...
more »

2017-08-14 17:08 (2) Answers

Sending parameter to a #define

I wonder to know is it possible to send a parameter to a #define macro for selecting different output For example: #define Row(1) LPC_GPIO0 #define Row(2) LPC_GPIO3 #define Row(3) LPC_GPIO2 Then in my code I create a loop for sending the paramete...
more »

2017-08-14 17:08 (3) Answers

C - GTKUibuilder - Glade - g_signal_connect error

I am trying to use Glade on my project to generate a file containing windows, grid ... But I am stuck wth an error when I try to listen to event clicked on my buttons, I do not understand why :s I got those errors.. GLib-GObject-WARNING **: invali...
more »

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