c

Memorable 32-bit value as a constant

I am looking for a memorable 32-bit value to be used as a constant. If possible, it should be somewhat funny too. So far, I have come up with these two: 0xcafebabe 0xdeaddad Can you please suggest some other too? Thank you. ...

What is the best language for sockets programming?

I'd like to develop software program that communicates between clients. What is the best programming language to do this? ...

Passing a structure by reference and manipulating it

typedef struct unit_class_struct { char *name; char *last_name; } person; int setName(person *array) { array[0].name = strdup("Bob"); array[1].name = strdup("Dick"); return 1; } int setLastName(person *array) { array->last_name = strdup("Sanchez"); array++; array->last_name = strdup("Clark"); re...

Steps to read data from ARM microcontroller port

I am having trouble reading serial data from ARM LPC2378 microcontroller. Will I have to use UART or any GPIO port can be used?? is ayone having c code for it?? ...

ncurses terminal size

How do I find the terminal width & height of an ncurses application? ...

C stdlib .h's on C++ and malloc/realloc

I was really bothered by the inclusion of C stdlib functions on the global namespace and ended up writing things like ::snprintf or ::errno or struct ::stat, etc, to differentiate from some of my own functions in the enclosing namespace where those c stdlib functions were used. Then I discovered that there is a way to declare every C st...

How to do a tree structure in C

I'm a very beginner in C. However, I need a program that solves a problem for me. How can I do the following? I need a tree structure. This is not traditional tree as every leaf can have various many leafs. Therefore every leaf should contain a linked list which contains the children of the leaf. In every link there is a char[][]-array ...

How to create a magnet link client (for ex for ThePiratBay)

How to create a magnet link downloader sharer using open source libs (C# if possible) ? What do I need: Open Source Libs/wrappers. Tutorials and blog articles on How to do it, about etc. ...

A question about union in C

I was reading about union in C from K&R, as far as I understood, a single variable in union can hold any one of the several types and if something is stored as one type and extracted as another the result is purely implementation defined. Now please check this code snippet: #include<stdio.h> int main(void){ union a{ int i; char c...

How to represent binary transparency?

Lately I've been interested in representing uncompressed bitmaps in memory. However, one thing I'm not sure how to implement properly is binary transparency. E.g., I start out with something like this: struct RGBPixel { uint8_t red; uint8_t green; uint8_t blue; }; struct bitmap { struct RGBPixel *data; size_t width; size_t height...

How to use magnet links in LibTorrent lib

How to use magnet links in LibTorrent C/C++ lib? I need an simple example of working with it - Something like I give him a link he gives me a file. ...

How do I find the derivative of sin(x) using recursion?

How do I find the derivative of sin(x) where x could be any value e.g. 1,2,3 using recursion? ...

Tips for designing a minimalist data store suitable for an embedded device.

I am trying to design a data store implementation like SQLite, BerkeleyDB or CouchDB suitable for a small embedded computer platform. The main criteria is minimal bloat and simple API. I could not find any products that fit my needs. SQLite is a tad too large and mimics relational databases. CouchDB has a good RESTful API but is bloated...

Reading values from file stream and storing them into a variable size array - OpenGL and C

Hi, I am trying to read the following file (The comments are not there in the original): Tetra.tri 4 4 // tot number of vertexes & tot number of triangles 0.693361 0.693361 0.693361 // vertex coordinates 0.693361 -0.693361 -0.693361 -0.693361 -0.693361 0.693361 -0.693361 0.693361 -0.693361 3 1 2 3 // triangles to display (the 3...

Do we have a thread library that is compatible with Turbo C?

Currently I am developing a program for academic purpose. We use Turbo C because we are requesting for interrupt directly with the hardware. We can do anything for our project, and I've already chosen a topic. The thing is I think I really need 2 threads in my program. Are there any thread libraries that are compatible with Turbo C in ...

unique elements - struct array

I have a sorted struct of IPs where I need to get the number of unique IPs, for some reason the way I'm doing it, is giving me a "0" as a result. Which in this case there should be 12 unique ips. The struct array containing the following elements: 195.55.121.242 212.80.168.34 65.55.106.114 65.55.207.30 65.55.207.95 65.55.230.237 ...

#define f(g,g2) g##g2

#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); } The above program prints 100 in c by concatenating var and 12. How does g##g2 work?? ...

Why does the call to bsearch() crash the presented program?

Hi, I have an unsorted dictionary file named "dict.txt". I have managed to put the words of the file in an array and the qsort() I use also seems to be working just fine (That is, the array is sorted). The problem arises when I call bsearch(), the program crashes and my question is: Why is this happening? I use gcc to compile and do...

void pointers and ffcall library

I'm using the ffcall (specifically the avcall package of ffcall) library to dynamically push parameters to variadic functions. i.e. we have int blah (char *a, int b, double c, ...); and we want to call this function with values taken from the user. To do this, we create an avcall version of the function: int av_blah (char *a, int b...

Why does C have a distinction between -> and . ?

OK, this is of no serious consequence, but it's been bugging me for a while: Is there a reason for the distinction between the -> and . operators? Of course, the current rule is that . acts on a struct, and -> acts on a pointer-to-struct (or union). But here's how it works in practice. Let s be a struct incuding an element x, and let p...