c

Good plotting library for C?

My question is very similar in spirit to this question: What is the best plotting library for Python? What is my best bet for plotting data in C? Am I better off forgoing a library and just generating data that I can feed directly into gnuplot? My impetus for this question is being able to visualize DSP transformations while studying ...

Non-blocking stdio

I'm working on a program which will be taking in user input from the console as well as printfing out in a separate thread. I want to avoid situations where the user is halfway through typing something in and a printf comes along and prints itself at the cursor. Is there a way to do non-blocking io in c from the console window? Ideally,...

Efficient Implementation of Fitness-Proportionate "Roulette" Selection

I am currently writing a keyboard layout optimization algorithm in C (such as the one designed by Peter Klausler) and I want to implement a fitness-proportionate selection as described here (PDF Link): With roulette selection you select members of the population based on a roullete wheel model. Make a pie chart, where the ar...

Are there conclusive studies/experiments on C compilation using a C++ compiler?

I've seen a lot of arguments over the general performance of C code compiled with a C++ compiler -- I'm curious as to whether there are any solid experimental studies buried beneath all the anecdotal flame wars you find in web searches. I'm particularly interested in the GCC suite, but any data points would be interesting. (Comparing the...

Getting IPV4 address from a sockaddr structure

How can I extract an IP address into a string? I can't find a reference that tells me how char sa_data[14] is encoded. ...

matrix pointer and function

Hello, I want to create a program wherein I can pass a matrix to a function using pointers. I initialized and scanned 2 matrices in the void main() and then i tried to pass them to a void add function. I think i am going wrong in the syntax of declaration and calling of the function. I assigned a pointer to the base address of my ma...

Install C C++ library under HOME shared via Network File System

Hi, My Home directory is shared among several linux computers via Network File System. I would like to install some C C++ library from source under my Home directory, and wish they can be used under all the linux computers. Do I have to install different versions of the library under different directories of my Home for different compu...

flex C exec file

is there any way to execute C language executable file from Flex? ...

Type selection for literal numeric values in C

Im wondering about this: when I try to assign an integer value to an int variable (16-bit compiler, 2 bytes for integers) lets say: int a; a=40000; that can't be represented with the range of the type it will be truncated. But what im seeing is that the resulting value in a is the bit pattern for -25000 (or some close number) wich me...

strtok and function call

I have this extremely strange behavior coming : In the below code: If I comment the call to MyLogger then everything works fine that is I get the sTempNr tokenized and 4 tokens are printed . But if I uncomment the call to MyLogger for logging then only the iteration takes place once and in other testing class with similar code as below ...

Runtime information in C daemon

The user, administrators and support staff need detailed runtime and monitoring information from a daemon developed in C. In my case these information are e.g. the current system health, like throughput (MB/s), already written data, ... the current configuration I would use JMX in the Java world and the procfs (or sysfs) interface ...

Function Pointer in C

How can I create a "function pointer" (and (for example) the function has parameters) in C? ...

How do I create a Win32 DLL without a dependency on the C runtime

Using Visual Studio 2008 and its C/C++ compiler, how do I create a Win32 DLL that is dependent only on other Windows DLLs, and has no dependency on the Microsoft C runtime? I have some C code I want to place in a DLL that is entirely computation, and makes almost no use of C library functions. For those it does use (eg memcpy), I'm hap...

Serial programming (hardware handshake)

I'm trying to to program a serial communication using hardware handshake in linux using C/C++. The signals that implement the handshake are CTS (Clear to send) and RTS (Request to send). Currently my function for setting the CTS signal looks as follows: int setCTS(int fd, int value) { int status; ioctl(fd, TIOCMGET, &status); //...

Converting unix timestamp to YYYY-MM-DD HH:MM:SS.

I have a Unix timestamp that I need to get the individual year, month, day, hour, minute and second values from. I never was very good in math class so I was wondering if you guys could help me out a little :) I have to do everything myself (no time.h functions). The language is C. ...

Code optimization

If I have a big structure(having lot of member variables). This structure pointer is passed to many functions in my code. Some member variables of this structure are used vary often, in almost all functions. If I put those frequently used member variables at the beginning in the structure declaration, will it optmize the code for MCP...

inotify 'main loop'

Hello, I am using inotify with "interupt io" by setting the O_ASYNC flag on the inotify file descriptor and then using fcntl(inotifyfd, F_SETOWN, getpid()) coupled with a signal(sighandler, SIGIO) call, all from a single process, in order to set up an inotify file descriptor event handler. The idea is to have inotify's file descriptor...

Embeddable language with good string manipulation support

I've been working on a C program which does quite a lot of string manipulation, and very often needs to be tweaked and recompiled for some sort of special case processing. I've been thinking that embedding some scripting language with good string manipulation support might make sense for the project. What language would provide the best...

How to find a subset of a 2d array by selecting rows and columns in c?

In an (m by n) array stored as double *d (column major), what is the fastest way of selecting a range of rows and or columns: double *filter(double *mat, int m, int n, int rows[], int cols[]); invoked as: double *B; int rows[]= {1,3,5}; int cols[]={2,4}; B = filter(A, 5, 4, rows, cols); which is expected to return a 3-by-2 subset ...

determine size of dynamically allocated memory in c

Is there a way in c to find out the size of dynamically allocated memory? For e.g., Suppose I say char* p = malloc(sizeof(char)*100); Now is there a way to find out the size of memory associated with p? ...